summaryrefslogtreecommitdiffstats
path: root/test/set_extent.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2008-10-02 19:56:45 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2008-10-02 19:56:45 (GMT)
commit8e97904f5ff0d16788be00f44db3d89dd8b5e14d (patch)
tree153f24bd4ffdc157d1818fd5b4e42f03bdbab532 /test/set_extent.c
parent4f7970f9f078942bcb7c1e92f98ed798ccc55025 (diff)
downloadhdf5-8e97904f5ff0d16788be00f44db3d89dd8b5e14d.zip
hdf5-8e97904f5ff0d16788be00f44db3d89dd8b5e14d.tar.gz
hdf5-8e97904f5ff0d16788be00f44db3d89dd8b5e14d.tar.bz2
[svn-r15757] Bug #1312
Solution: Check for the existence of chunks before pruning them (an assertion was triggered when attempting to do so) Tested: windows , linux, solaris
Diffstat (limited to 'test/set_extent.c')
-rw-r--r--test/set_extent.c453
1 files changed, 319 insertions, 134 deletions
diff --git a/test/set_extent.c b/test/set_extent.c
index 24d6851..911a9a0 100644
--- a/test/set_extent.c
+++ b/test/set_extent.c
@@ -39,15 +39,16 @@
int main( void )
{
- hid_t file_id;
- hid_t dataset_id=(-1);
- hid_t space_id=(-1);
- hid_t plist_id=(-1);
- hid_t fcpl; /* File creation property list */
+ hid_t fid;
+ hid_t did=(-1);
+ hid_t sid=(-1);
+ hid_t dcpl=(-1);
+ hid_t fcpl;
hsize_t dims[RANK] = { 90, 90 };
hsize_t dims_new[RANK] = { 70, 70 };
hsize_t dims_chunk[RANK] = { 20, 20 };
hsize_t dims_out[RANK];
+ hsize_t dims3[RANK];
hsize_t maxdims[RANK] = { H5S_UNLIMITED, H5S_UNLIMITED };
int data[ 90 ][ 90 ];
int buf1[ 70 ][ 70 ];
@@ -55,7 +56,7 @@ int main( void )
int i, j, n = 0;
int fillvalue = 1; /* Fill value for the dataset */
#ifdef H5_HAVE_FILTER_DEFLATE
- hbool_t do_compress; /* Iterator for looping over compress/no compress */
+ hbool_t do_compress; /* Iterator for looping over compress/no compress */
#endif /* H5_HAVE_FILTER_DEFLATE */
@@ -68,7 +69,8 @@ int main( void )
*-------------------------------------------------------------------------
*/
#ifdef H5_HAVE_FILTER_DEFLATE
- for(do_compress = FALSE; do_compress <= TRUE; do_compress++) {
+ for (do_compress = FALSE; do_compress <= TRUE; do_compress++)
+ {
if(do_compress)
puts("Testing WITH compression on chunks.");
else
@@ -80,18 +82,26 @@ int main( void )
TESTING("extend dataset create with fill value");
/* Create a new file using default properties. */
- if((file_id = H5Fcreate("set_extent_create.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((fid = H5Fcreate("set_extent_create.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create the data space with unlimited dimensions. */
- if((space_id = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR;
+ if((sid = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ TEST_ERROR;
/* Modify dataset creation properties, i.e. enable chunking. */
- if((plist_id = H5Pcreate (H5P_DATASET_CREATE)) < 0) TEST_ERROR;
- if(H5Pset_chunk(plist_id, RANK, dims_chunk) < 0) TEST_ERROR;
- if(H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue) < 0) TEST_ERROR;
+ if((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR;
+ if(H5Pset_chunk(dcpl, RANK, dims_chunk) < 0)
+ TEST_ERROR;
+ if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0)
+ TEST_ERROR;
#ifdef H5_HAVE_FILTER_DEFLATE
if(do_compress)
- if(H5Pset_deflate(plist_id, 9) < 0) FAIL_STACK_ERROR
+ {
+ if(H5Pset_deflate(dcpl, 9) < 0)
+ FAIL_STACK_ERROR
+ }
#endif /* H5_HAVE_FILTER_DEFLATE */
@@ -101,10 +111,12 @@ int main( void )
*/
/* Create a new dataset */
- if((dataset_id = H5Dcreate2(file_id , "Dataset1", H5T_NATIVE_INT, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((did = H5Dcreate2(fid , "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Write the data. */
- if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR;
+ if(H5Dwrite(did , H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, data) < 0)
+ TEST_ERROR;
/*-------------------------------------------------------------------------
* Set new dimensions for the array; shrink it
@@ -112,16 +124,21 @@ int main( void )
*/
/* Set new dimensions for the array. */
- if(H5Dset_extent(dataset_id , dims_new) < 0) TEST_ERROR;
+ if(H5Dset_extent(did , dims_new) < 0)
+ TEST_ERROR;
/* Get the space. */
- if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR;
+ if((sid = H5Dget_space(did)) < 0)
+ TEST_ERROR;
/* Get dimensions. */
- if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR;
+ if(H5Sget_simple_extent_dims(sid, dims_out, NULL) < 0)
+ TEST_ERROR;
- if(dims_out[0] != dims_new[0]) TEST_ERROR;
- if(dims_out[1] != dims_new[1]) TEST_ERROR;
+ if(dims_out[0] != dims_new[0])
+ TEST_ERROR;
+ if(dims_out[1] != dims_new[1])
+ TEST_ERROR;
/*-------------------------------------------------------------------------
@@ -130,17 +147,23 @@ int main( void )
*/
/* Read the new dataset. */
- if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 ) < 0) TEST_ERROR;
+ if (H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 ) < 0)
+ TEST_ERROR;
/* Compare the read array with the original array */
for( i = 0; i < (int)dims_out[0]; i++ )
+ {
for( j = 0; j < (int)dims_out[1]; j++ )
- if ( buf1[i][j] != data[i][j] ) {
+ {
+ if ( buf1[i][j] != data[i][j] )
+ {
printf("buf1[%d][%d] = %d\n", i, j, buf1[i][j]);
printf("data[%d][%d] = %d\n", i, j, data[i][j]);
TEST_ERROR;
- } /* end if */
+ }
+ }
+ }
/*-------------------------------------------------------------------------
@@ -149,16 +172,21 @@ int main( void )
*/
/* Set new dimensions for the array. */
- if(H5Dset_extent(dataset_id, dims) < 0) TEST_ERROR;
+ if(H5Dset_extent(did, dims) < 0)
+ TEST_ERROR;
/* Get the space. */
- if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR;
+ if((sid = H5Dget_space(did)) < 0)
+ TEST_ERROR;
/* Get dimensions. */
- if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR;
+ if(H5Sget_simple_extent_dims(sid, dims_out, NULL) < 0)
+ TEST_ERROR;
- if(dims_out[0] != dims[0]) TEST_ERROR;
- if(dims_out[1] != dims[1]) TEST_ERROR;
+ if(dims_out[0] != dims[0])
+ TEST_ERROR;
+ if(dims_out[1] != dims[1])
+ TEST_ERROR;
/*-------------------------------------------------------------------------
@@ -167,21 +195,29 @@ int main( void )
*/
/* Read the new dataset. */
- if(H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0) TEST_ERROR;
+ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0)
+ TEST_ERROR;
/* Compare the read array with the original array */
for(i = 0; i < (int)dims_out[0]; i++ )
+ {
for(j = 0; j < (int)dims_out[1]; j++ )
- if(i >= 70 || j >= 70) {
+ {
+ if(i >= 70 || j >= 70)
+ {
if(buf2[i][j] != fillvalue) {
printf("buf1[%d][%d] = %d\n", i, j, buf1[i][j]);
printf("fillvalue = %d\n", fillvalue);
TEST_ERROR;
} /* end if */
} /* end if */
- else {
- if(buf2[i][j] != data[i][j]) TEST_ERROR;
+ else
+ {
+ if(buf2[i][j] != data[i][j])
+ TEST_ERROR;
}
+ }
+ }
/*-------------------------------------------------------------------------
@@ -189,9 +225,12 @@ int main( void )
*-------------------------------------------------------------------------
*/
- if(H5Dclose(dataset_id) < 0) TEST_ERROR
- if(H5Sclose(space_id) < 0) TEST_ERROR
- if(H5Pclose(plist_id) < 0) TEST_ERROR
+ if(H5Dclose(did) < 0)
+ TEST_ERROR
+ if(H5Sclose(sid) < 0)
+ TEST_ERROR
+ if(H5Pclose(dcpl) < 0)
+ TEST_ERROR
PASSED();
@@ -199,15 +238,20 @@ int main( void )
TESTING("extend dataset create without fill value");
/* Create the data space with unlimited dimensions. */
- if((space_id = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR;
+ if((sid = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ TEST_ERROR;
/* Modify dataset creation properties, i.e. enable chunking. */
- if((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
- if(H5Pset_chunk(plist_id, RANK, dims_chunk) < 0) TEST_ERROR;
- if(H5Pset_fill_time(plist_id, H5D_FILL_TIME_ALLOC) < 0) TEST_ERROR;
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR;
+ if(H5Pset_chunk(dcpl, RANK, dims_chunk) < 0)
+ TEST_ERROR;
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0)
+ TEST_ERROR;
#ifdef H5_HAVE_FILTER_DEFLATE
if(do_compress)
- if(H5Pset_deflate(plist_id, 9) < 0) FAIL_STACK_ERROR
+ if(H5Pset_deflate(dcpl, 9) < 0)
+ FAIL_STACK_ERROR
#endif /* H5_HAVE_FILTER_DEFLATE */
/*-------------------------------------------------------------------------
@@ -216,10 +260,12 @@ int main( void )
*/
/* Create a new dataset */
- if((dataset_id = H5Dcreate2(file_id , "Dataset2", H5T_NATIVE_INT, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((did = H5Dcreate2(fid , "Dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Write the data. */
- if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR;
+ if(H5Dwrite(did , H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, data) < 0)
+ TEST_ERROR;
/*-------------------------------------------------------------------------
* Set new dimensions for the array; shrink it
@@ -227,15 +273,19 @@ int main( void )
*/
/* Set new dimensions for the array. */
- if(H5Dset_extent(dataset_id , dims_new) < 0) TEST_ERROR;
+ if(H5Dset_extent(did , dims_new) < 0)
+ TEST_ERROR;
/* Get the space. */
- if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR;
+ if((sid = H5Dget_space(did)) < 0)
+ TEST_ERROR;
/* Get dimensions. */
- if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR;
+ if(H5Sget_simple_extent_dims(sid, dims_out, NULL) < 0)
+ TEST_ERROR;
- if(dims_out[0] != dims_new[0]) TEST_ERROR;
+ if(dims_out[0] != dims_new[0])
+ TEST_ERROR;
/*-------------------------------------------------------------------------
@@ -244,13 +294,19 @@ int main( void )
*/
/* Read the new dataset. */
- if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 ) < 0) TEST_ERROR;
+ if (H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 ) < 0)
+ TEST_ERROR;
/* Compare the read array with the original array */
for( i = 0; i < (int)dims_out[0]; i++ )
+ {
for( j = 0; j < (int)dims_out[1]; j++ )
- if ( buf1[i][j] != data[i][j] ) TEST_ERROR;
+ {
+ if ( buf1[i][j] != data[i][j] )
+ TEST_ERROR;
+ }
+ }
/*-------------------------------------------------------------------------
@@ -259,15 +315,19 @@ int main( void )
*/
/* Set new dimensions for the array. */
- if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR;
+ if (H5Dset_extent( did , dims ) < 0)
+ TEST_ERROR;
/* Get the space. */
- if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR;
+ if ((sid = H5Dget_space( did )) < 0)
+ TEST_ERROR;
/* Get dimensions. */
- if (H5Sget_simple_extent_dims( space_id, dims_out, NULL ) < 0) TEST_ERROR;
+ if (H5Sget_simple_extent_dims( sid, dims_out, NULL ) < 0)
+ TEST_ERROR;
- if ( dims_out[0] != dims[0] ) TEST_ERROR;
+ if ( dims_out[0] != dims[0] )
+ TEST_ERROR;
/*-------------------------------------------------------------------------
@@ -276,16 +336,21 @@ int main( void )
*/
/* Read the new dataset. */
- if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 ) < 0) TEST_ERROR;
+ if (H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 ) < 0)
+ TEST_ERROR;
/* Compare the read array with the original array */
- for( i = 0; i < (int)dims_out[0]; i++ ) {
- for( j = 0; j < (int)dims_out[1]; j++ ) {
+ for( i = 0; i < (int)dims_out[0]; i++ )
+ {
+ for( j = 0; j < (int)dims_out[1]; j++ )
+ {
if ( i >= 70 || j >= 70 ) {
- if ( buf2[i][j] != 0 ) TEST_ERROR;
+ if ( buf2[i][j] != 0 )
+ TEST_ERROR;
}
else {
- if ( buf2[i][j] != data[i][j] ) TEST_ERROR;
+ if ( buf2[i][j] != data[i][j] )
+ TEST_ERROR;
}
}
}
@@ -296,11 +361,14 @@ int main( void )
*-------------------------------------------------------------------------
*/
- H5Dclose( dataset_id );
- H5Sclose( space_id );
- H5Pclose( plist_id );
-
- H5Fclose( file_id );
+ if (H5Dclose(did) < 0)
+ TEST_ERROR
+ if (H5Sclose(sid) < 0)
+ TEST_ERROR
+ if (H5Pclose(dcpl) < 0)
+ TEST_ERROR
+ if (H5Fclose( fid ) < 0)
+ TEST_ERROR
PASSED();
@@ -312,69 +380,91 @@ int main( void )
*/
/* Create a file creation property list */
- if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR;
+ if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
+ TEST_ERROR;
/* Set non-default indexed storage B-tree internal 'K' value */
- if(H5Pset_istore_k(fcpl,ISTORE_IK) < 0) TEST_ERROR;
+ if(H5Pset_istore_k(fcpl,ISTORE_IK) < 0)
+ TEST_ERROR;
/* Create a new file using properties. */
- if((file_id = H5Fcreate("set_extent_read.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((fid = H5Fcreate("set_extent_read.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Close property list */
- if(H5Pclose(fcpl) < 0) TEST_ERROR;
+ if(H5Pclose(fcpl) < 0)
+ TEST_ERROR;
TESTING("extend dataset read with fill value");
/* Create the data space with unlimited dimensions. */
- if((space_id = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR;
+ if((sid = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ TEST_ERROR;
/* Modify dataset creation properties, i.e. enable chunking. */
- if((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
- if(H5Pset_chunk(plist_id, RANK, dims_chunk) < 0) TEST_ERROR;
- if(H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue) < 0) TEST_ERROR;
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR;
+ if(H5Pset_chunk(dcpl, RANK, dims_chunk) < 0)
+ TEST_ERROR;
+ if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillvalue) < 0)
+ TEST_ERROR;
#ifdef H5_HAVE_FILTER_DEFLATE
if(do_compress)
- if(H5Pset_deflate(plist_id, 9) < 0) FAIL_STACK_ERROR
+ if(H5Pset_deflate(dcpl, 9) < 0)
+ FAIL_STACK_ERROR
#endif /* H5_HAVE_FILTER_DEFLATE */
/* Create a new dataset within the file using cparms creation properties. */
- if((dataset_id = H5Dcreate2(file_id , "Dataset1", H5T_NATIVE_INT, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((did = H5Dcreate2(fid , "Dataset1", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Write the data. */
- if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR;
+ if(H5Dwrite(did , H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, data) < 0)
+ TEST_ERROR;
/* Close/release resources. */
- if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR
- if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR
- if(H5Pclose(plist_id) < 0) FAIL_STACK_ERROR
- if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
/* Open the file */
- if((file_id = H5Fopen("set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((fid = H5Fopen("set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Open the dataset */
- if((dataset_id = H5Dopen2(file_id , "Dataset1", H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((did = H5Dopen2(fid , "Dataset1", H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Set new dimensions for the array. */
- if(H5Dset_extent(dataset_id, dims_new) < 0) TEST_ERROR;
+ if(H5Dset_extent(did, dims_new) < 0)
+ TEST_ERROR;
/* Get the space. */
- if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR;
+ if((sid = H5Dget_space(did)) < 0)
+ TEST_ERROR;
/* Get dimensions. */
- if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR;
+ if(H5Sget_simple_extent_dims(sid, dims_out, NULL) < 0)
+ TEST_ERROR;
- if(dims_out[0] != dims_new[0]) TEST_ERROR;
+ if(dims_out[0] != dims_new[0])
+ TEST_ERROR;
/* Read the new dataset. */
- if(H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0) TEST_ERROR;
+ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0)
+ TEST_ERROR;
/* Compare the read array with the original array */
for(i = 0; i < (int)dims_out[0]; i++)
+ {
for(j = 0; j < (int)dims_out[1]; j++)
+ {
if(buf1[i][j] != data[i][j])
TEST_ERROR;
+ }
+ }
/*-------------------------------------------------------------------------
* Set new dimensions for the array; expand it again
@@ -382,27 +472,38 @@ int main( void )
*/
/* Set new dimensions for the array. */
- if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR;
+ if (H5Dset_extent( did , dims ) < 0)
+ TEST_ERROR;
/* Get the space. */
- if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR;
+ if ((sid = H5Dget_space( did )) < 0)
+ TEST_ERROR;
/* Get dimensions. */
- if (H5Sget_simple_extent_dims( space_id, dims_out, NULL ) < 0) TEST_ERROR;
+ if (H5Sget_simple_extent_dims( sid, dims_out, NULL ) < 0)
+ TEST_ERROR;
- if ( dims_out[0] != dims[0] ) TEST_ERROR;
+ if ( dims_out[0] != dims[0] )
+ TEST_ERROR;
/* Read the new dataset. */
- if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 ) < 0) TEST_ERROR;
+ if (H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 ) < 0)
+ TEST_ERROR;
/* Compare the read array with the original array */
- for( i = 0; i < (int)dims_out[0]; i++ ) {
- for( j = 0; j < (int)dims_out[1]; j++ ) {
- if ( i >= 70 || j >= 70 ) {
- if ( buf2[i][j] != fillvalue ) TEST_ERROR;
+ for( i = 0; i < (int)dims_out[0]; i++ )
+ {
+ for( j = 0; j < (int)dims_out[1]; j++ )
+ {
+ if ( i >= 70 || j >= 70 )
+ {
+ if ( buf2[i][j] != fillvalue )
+ TEST_ERROR;
}
- else {
- if ( buf2[i][j] != data[i][j] ) TEST_ERROR;
+ else
+ {
+ if ( buf2[i][j] != data[i][j] )
+ TEST_ERROR;
}
}
}
@@ -413,8 +514,10 @@ int main( void )
*-------------------------------------------------------------------------
*/
- H5Dclose( dataset_id );
- H5Sclose( space_id );
+ if (H5Dclose(did) < 0)
+ TEST_ERROR
+ if (H5Sclose(sid) < 0)
+ TEST_ERROR
PASSED();
@@ -422,55 +525,73 @@ int main( void )
TESTING("extend dataset read without fill value");
/* Create the data space with unlimited dimensions. */
- if((space_id = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR;
+ if((sid = H5Screate_simple(RANK, dims, maxdims)) < 0)
+ TEST_ERROR;
/* Modify dataset creation properties, i.e. enable chunking. */
- if((plist_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
- if(H5Pset_chunk(plist_id, RANK, dims_chunk) < 0) TEST_ERROR;
- if(H5Pset_fill_time(plist_id, H5D_FILL_TIME_ALLOC) < 0) TEST_ERROR;
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR;
+ if(H5Pset_chunk(dcpl, RANK, dims_chunk) < 0)
+ TEST_ERROR;
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0)
+ TEST_ERROR;
#ifdef H5_HAVE_FILTER_DEFLATE
if(do_compress)
- if(H5Pset_deflate(plist_id, 9) < 0) FAIL_STACK_ERROR
+ if(H5Pset_deflate(dcpl, 9) < 0)
+ FAIL_STACK_ERROR
#endif /* H5_HAVE_FILTER_DEFLATE */
/* Create a new dataset within the file using cparms creation properties. */
- if((dataset_id = H5Dcreate2(file_id , "Dataset2", H5T_NATIVE_INT, space_id, H5P_DEFAULT, plist_id, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((did = H5Dcreate2(fid , "Dataset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Write the data. */
- if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR;
+ if(H5Dwrite(did , H5T_NATIVE_INT, sid, H5S_ALL, H5P_DEFAULT, data) < 0)
+ TEST_ERROR;
/* Close/release resources. */
- if(H5Dclose(dataset_id) < 0) FAIL_STACK_ERROR
- if(H5Sclose(space_id) < 0) FAIL_STACK_ERROR
- if(H5Pclose(plist_id) < 0) FAIL_STACK_ERROR
- if(H5Fclose(file_id) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
/* Open the file */
- if((file_id = H5Fopen("set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((fid = H5Fopen("set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Open the dataset */
- if((dataset_id = H5Dopen2(file_id , "Dataset2", H5P_DEFAULT)) < 0) TEST_ERROR;
+ if((did = H5Dopen2(fid , "Dataset2", H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Set new dimensions for the array. */
- if(H5Dset_extent(dataset_id, dims_new) < 0) TEST_ERROR;
+ if(H5Dset_extent(did, dims_new) < 0)
+ TEST_ERROR;
/* Get the space. */
- if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR;
+ if((sid = H5Dget_space(did)) < 0)
+ TEST_ERROR;
/* Get dimensions. */
- if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR;
+ if(H5Sget_simple_extent_dims(sid, dims_out, NULL) < 0)
+ TEST_ERROR;
- if(dims_out[0] != dims_new[0]) TEST_ERROR;
+ if(dims_out[0] != dims_new[0])
+ TEST_ERROR;
/* Read the new dataset. */
- if(H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0) TEST_ERROR;
+ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0)
+ TEST_ERROR;
/* Compare the read array with the original array */
for(i = 0; i < (int)dims_out[0]; i++)
+ {
for(j = 0; j < (int)dims_out[1]; j++)
+ {
if(buf1[i][j] != data[i][j])
TEST_ERROR;
+ }
+ }
/*-------------------------------------------------------------------------
* Set new dimensions for the array; expand it again
@@ -478,44 +599,108 @@ int main( void )
*/
/* Set new dimensions for the array. */
- if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR;
+ if (H5Dset_extent( did , dims ) < 0)
+ TEST_ERROR;
/* Get the space. */
- if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR;
+ if ((sid = H5Dget_space( did )) < 0)
+ TEST_ERROR;
/* Get dimensions. */
- if (H5Sget_simple_extent_dims( space_id, dims_out, NULL ) < 0) TEST_ERROR;
+ if (H5Sget_simple_extent_dims( sid, dims_out, NULL ) < 0)
+ TEST_ERROR;
- if ( dims_out[0] != dims[0] ) TEST_ERROR;
+ if ( dims_out[0] != dims[0] )
+ TEST_ERROR;
/* Read the new dataset. */
- if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 ) < 0) TEST_ERROR;
+ if (H5Dread( did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 ) < 0)
+ TEST_ERROR;
/* Compare the read array with the original array */
- for( i = 0; i < (int)dims_out[0]; i++ ) {
- for( j = 0; j < (int)dims_out[1]; j++ ) {
- if ( i >= 70 || j >= 70 ) {
- if ( buf2[i][j] != 0 ) TEST_ERROR;
+ for( i = 0; i < (int)dims_out[0]; i++ )
+ {
+ for( j = 0; j < (int)dims_out[1]; j++ )
+ {
+ if ( i >= 70 || j >= 70 )
+ {
+ if ( buf2[i][j] != 0 )
+ TEST_ERROR;
}
- else {
- if ( buf2[i][j] != data[i][j] ) TEST_ERROR;
+ else
+ {
+ if ( buf2[i][j] != data[i][j] )
+ TEST_ERROR;
}
}
}
/*-------------------------------------------------------------------------
- * Close/release resources
+ * close
+ *-------------------------------------------------------------------------
+ */
+
+ if (H5Dclose(did) < 0)
+ TEST_ERROR
+ if (H5Sclose(sid) < 0)
+ TEST_ERROR
+ if (H5Fclose( fid ) < 0)
+ TEST_ERROR
+
+ PASSED();
+
+
+
+ /*-------------------------------------------------------------------------
+ * test a dataset with initialized chunks
*-------------------------------------------------------------------------
*/
- H5Dclose( dataset_id );
- H5Sclose( space_id );
+ TESTING("initialized chunks");
+ dims3[ 0 ] = 90;
+ dims3[ 1 ] = 90;
- H5Fclose( file_id );
+ if ((fid = H5Fopen("set_extent_create.h5", H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ if ((sid = H5Screate_simple(RANK, dims3, maxdims)) < 0)
+ TEST_ERROR;
+ if ((dcpl = H5Pcreate (H5P_DATASET_CREATE)) < 0)
+ TEST_ERROR;
+ if (H5Pset_chunk(dcpl, RANK, dims_chunk) < 0)
+ TEST_ERROR;
+#ifdef H5_HAVE_FILTER_DEFLATE
+ if(do_compress)
+ {
+ if(H5Pset_deflate(dcpl, 9) < 0)
+ FAIL_STACK_ERROR
+ }
+#endif /* H5_HAVE_FILTER_DEFLATE */
+ /* create a new dataset */
+ if((did = H5Dcreate2(fid , "Dataset3", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* set new dimensions for the array */
+ dims3[ 0 ] = 0;
+ dims3[ 1 ] = 0;
+ if (H5Dset_extent( did , dims3 ) < 0)
+ TEST_ERROR;
+
+
+ if (H5Dclose(did) < 0)
+ TEST_ERROR
+ if (H5Sclose(sid) < 0)
+ TEST_ERROR
+ if (H5Pclose(dcpl) < 0)
+ TEST_ERROR
+ if (H5Fclose( fid ) < 0)
+ TEST_ERROR
+
PASSED();
+
+
#ifdef H5_HAVE_FILTER_DEFLATE
} /* end for */
#endif /* H5_HAVE_FILTER_DEFLATE */
@@ -525,10 +710,10 @@ int main( void )
error:
- H5Dclose( dataset_id );
- H5Sclose( space_id );
- H5Pclose( plist_id );
- H5Fclose( file_id );
+ H5Dclose( did );
+ H5Sclose( sid );
+ H5Pclose( dcpl );
+ H5Fclose( fid );
H5_FAILED();
return 1;
}