diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/set_extent.c | 617 |
1 files changed, 324 insertions, 293 deletions
diff --git a/test/set_extent.c b/test/set_extent.c index aa94b82..24d6851 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -39,7 +39,6 @@ int main( void ) { - hid_t file_id; hid_t dataset_id=(-1); hid_t space_id=(-1); @@ -55,6 +54,9 @@ int main( void ) int buf2[ 90 ][ 90 ]; 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 */ +#endif /* H5_HAVE_FILTER_DEFLATE */ for( i = 0; i < 90; i++ ) @@ -65,429 +67,458 @@ int main( void ) * Test H5Dset_extent with chunks on the raw data cache *------------------------------------------------------------------------- */ +#ifdef H5_HAVE_FILTER_DEFLATE + for(do_compress = FALSE; do_compress <= TRUE; do_compress++) { + if(do_compress) + puts("Testing WITH compression on chunks."); + else + puts("Testing with NO compression on chunks."); +#else /* H5_HAVE_FILTER_DEFLATE */ + puts("** deflate filter nor available - Skipping tests for compression on chunks. **"); +#endif /* H5_HAVE_FILTER_DEFLATE */ + 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; + /* 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; - TESTING("extend dataset create with fill value"); + /* Create the data space with unlimited dimensions. */ + if((space_id = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR; - /* Create the data space with unlimited dimensions. */ - if((space_id = 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; +#ifdef H5_HAVE_FILTER_DEFLATE + if(do_compress) + if(H5Pset_deflate(plist_id, 9) < 0) FAIL_STACK_ERROR +#endif /* H5_HAVE_FILTER_DEFLATE */ - /* 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; + /*------------------------------------------------------------------------- + * Create and write one dataset + *------------------------------------------------------------------------- + */ - /*------------------------------------------------------------------------- - * Create and write one dataset - *------------------------------------------------------------------------- - */ + /* 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; - /* 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; + /* Write the data. */ + if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; - /* Write the data. */ - if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; + /*------------------------------------------------------------------------- + * Set new dimensions for the array; shrink it + *------------------------------------------------------------------------- + */ - /*------------------------------------------------------------------------- - * Set new dimensions for the array; shrink it - *------------------------------------------------------------------------- - */ + /* Set new dimensions for the array. */ + if(H5Dset_extent(dataset_id , dims_new) < 0) TEST_ERROR; - /* Set new dimensions for the array. */ - if(H5Dset_extent(dataset_id , dims_new) < 0) TEST_ERROR; + /* Get the space. */ + if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR; - /* Get the space. */ - if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR; + /* Get dimensions. */ + if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR; - /* Get dimensions. */ - if(H5Sget_simple_extent_dims(space_id, 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; + /*------------------------------------------------------------------------- + * Read + *------------------------------------------------------------------------- + */ - /*------------------------------------------------------------------------- - * Read - *------------------------------------------------------------------------- - */ + /* Read the new dataset. */ + if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 ) < 0) TEST_ERROR; - /* Read the new dataset. */ - if (H5Dread( dataset_id, 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] ) { + 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 */ - /* 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] ) { - 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 */ + /*------------------------------------------------------------------------- + * Set new dimensions for the array; expand it back to original size + *------------------------------------------------------------------------- + */ - /*------------------------------------------------------------------------- - * Set new dimensions for the array; expand it back to original size - *------------------------------------------------------------------------- - */ - - /* Set new dimensions for the array. */ - if(H5Dset_extent(dataset_id, dims) < 0) TEST_ERROR; + /* Set new dimensions for the array. */ + if(H5Dset_extent(dataset_id, dims) < 0) TEST_ERROR; - /* Get the space. */ - if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR; + /* Get the space. */ + if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR; - /* Get dimensions. */ - if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR; + /* Get dimensions. */ + if(H5Sget_simple_extent_dims(space_id, 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; - /*------------------------------------------------------------------------- - * Read - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Read + *------------------------------------------------------------------------- + */ - /* Read the new dataset. */ - if(H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0) TEST_ERROR; + /* Read the new dataset. */ + if(H5Dread(dataset_id, 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) { - printf("buf1[%d][%d] = %d\n", i, j, buf1[i][j]); - printf("fillvalue = %d\n", fillvalue); - 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) { + printf("buf1[%d][%d] = %d\n", i, j, buf1[i][j]); + printf("fillvalue = %d\n", fillvalue); + TEST_ERROR; + } /* end if */ } /* end if */ - } /* end if */ - else { - if(buf2[i][j] != data[i][j]) TEST_ERROR; - } + else { + if(buf2[i][j] != data[i][j]) TEST_ERROR; + } - /*------------------------------------------------------------------------- - * Close/release resources - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Close/release resources + *------------------------------------------------------------------------- + */ - if(H5Dclose(dataset_id) < 0) TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(H5Pclose(plist_id) < 0) TEST_ERROR + if(H5Dclose(dataset_id) < 0) TEST_ERROR + if(H5Sclose(space_id) < 0) TEST_ERROR + if(H5Pclose(plist_id) < 0) TEST_ERROR - PASSED(); - TESTING("extend dataset create without fill value"); + PASSED(); - /* Create the data space with unlimited dimensions. */ - if((space_id = 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; + TESTING("extend dataset create without fill value"); - /*------------------------------------------------------------------------- - * Create and write one dataset - *------------------------------------------------------------------------- - */ + /* Create the data space with unlimited dimensions. */ + if((space_id = H5Screate_simple(RANK, dims, maxdims)) < 0) TEST_ERROR; - /* 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; + /* 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; +#ifdef H5_HAVE_FILTER_DEFLATE + if(do_compress) + if(H5Pset_deflate(plist_id, 9) < 0) FAIL_STACK_ERROR +#endif /* H5_HAVE_FILTER_DEFLATE */ - /* Write the data. */ - if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; + /*------------------------------------------------------------------------- + * Create and write one dataset + *------------------------------------------------------------------------- + */ - /*------------------------------------------------------------------------- - * Set new dimensions for the array; shrink it - *------------------------------------------------------------------------- - */ + /* 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; - /* Set new dimensions for the array. */ - if(H5Dset_extent(dataset_id , dims_new) < 0) TEST_ERROR; + /* Write the data. */ + if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; - /* Get the space. */ - if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR; + /*------------------------------------------------------------------------- + * Set new dimensions for the array; shrink it + *------------------------------------------------------------------------- + */ - /* Get dimensions. */ - if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR; + /* Set new dimensions for the array. */ + if(H5Dset_extent(dataset_id , dims_new) < 0) TEST_ERROR; - if(dims_out[0] != dims_new[0]) TEST_ERROR; + /* Get the space. */ + if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR; + /* Get dimensions. */ + if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR; - /*------------------------------------------------------------------------- - * Read - *------------------------------------------------------------------------- - */ + 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; + /*------------------------------------------------------------------------- + * Read + *------------------------------------------------------------------------- + */ - /* 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; + /* Read the new dataset. */ + if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 ) < 0) TEST_ERROR; - /*------------------------------------------------------------------------- - * Set new dimensions for the array; expand it again - *------------------------------------------------------------------------- - */ + /* 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. */ - if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR; - /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR; + /*------------------------------------------------------------------------- + * Set new dimensions for the array; expand it again + *------------------------------------------------------------------------- + */ - /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL ) < 0) TEST_ERROR; + /* Set new dimensions for the array. */ + if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR; - if ( dims_out[0] != dims[0] ) TEST_ERROR; + /* Get the space. */ + if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR; + /* Get dimensions. */ + if (H5Sget_simple_extent_dims( space_id, dims_out, NULL ) < 0) TEST_ERROR; - /*------------------------------------------------------------------------- - * Read - *------------------------------------------------------------------------- - */ + 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; - /* 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; - } - else { - if ( buf2[i][j] != data[i][j] ) TEST_ERROR; + /*------------------------------------------------------------------------- + * Read + *------------------------------------------------------------------------- + */ + + /* Read the new dataset. */ + if (H5Dread( dataset_id, 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; + } + else { + if ( buf2[i][j] != data[i][j] ) TEST_ERROR; + } } } - } - /*------------------------------------------------------------------------- - * Close/release resources - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Close/release resources + *------------------------------------------------------------------------- + */ - H5Dclose( dataset_id ); - H5Sclose( space_id ); - H5Pclose( plist_id ); + H5Dclose( dataset_id ); + H5Sclose( space_id ); + H5Pclose( plist_id ); - H5Fclose( file_id ); + H5Fclose( file_id ); - PASSED(); + PASSED(); - /*------------------------------------------------------------------------- - * Test H5Dset_extent with chunks written to file - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Test H5Dset_extent with chunks written to file + *------------------------------------------------------------------------- + */ - /* Create a file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) TEST_ERROR; + /* Create a file creation property list */ + 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; + /* Set non-default indexed storage B-tree internal 'K' value */ + 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; + /* Create a new file using properties. */ + if((file_id = H5Fcreate("set_extent_read.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) TEST_ERROR; - /* Close property list */ - if(H5Pclose(fcpl) < 0) TEST_ERROR; + /* Close property list */ + if(H5Pclose(fcpl) < 0) TEST_ERROR; - TESTING("extend dataset read with fill value"); + 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; + /* Create the data space with unlimited dimensions. */ + if((space_id = 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; + /* 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; +#ifdef H5_HAVE_FILTER_DEFLATE + if(do_compress) + if(H5Pset_deflate(plist_id, 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; + /* 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; - /* Write the data. */ - if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; + /* Write the data. */ + if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, 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 + /* 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 - /* Open the file */ - if((file_id = H5Fopen("set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR; + /* Open the file */ + if((file_id = 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; + /* Open the dataset */ + if((dataset_id = H5Dopen2(file_id , "Dataset1", H5P_DEFAULT)) < 0) TEST_ERROR; - /* Set new dimensions for the array. */ - if(H5Dset_extent(dataset_id, dims_new) < 0) TEST_ERROR; + /* Set new dimensions for the array. */ + if(H5Dset_extent(dataset_id, dims_new) < 0) TEST_ERROR; - /* Get the space. */ - if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR; + /* Get the space. */ + if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR; - /* Get dimensions. */ - if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR; + /* Get dimensions. */ + if(H5Sget_simple_extent_dims(space_id, 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; + /* Read the new dataset. */ + if(H5Dread(dataset_id, 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; + /* 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 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Set new dimensions for the array; expand it again + *------------------------------------------------------------------------- + */ - /* Set new dimensions for the array. */ - if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR; + /* Set new dimensions for the array. */ + if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR; - /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR; + /* Get the space. */ + if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR; - /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL ) < 0) TEST_ERROR; + /* Get dimensions. */ + if (H5Sget_simple_extent_dims( space_id, 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; + /* Read the new dataset. */ + if (H5Dread( dataset_id, 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; - } - else { - if ( buf2[i][j] != data[i][j] ) 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; + } + else { + if ( buf2[i][j] != data[i][j] ) TEST_ERROR; + } } } - } - /*------------------------------------------------------------------------- - * Close/release resources - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Close/release resources + *------------------------------------------------------------------------- + */ - H5Dclose( dataset_id ); - H5Sclose( space_id ); + H5Dclose( dataset_id ); + H5Sclose( space_id ); - PASSED(); + PASSED(); - TESTING("extend dataset read without fill value"); + 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; + /* Create the data space with unlimited dimensions. */ + if((space_id = 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; + /* 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; +#ifdef H5_HAVE_FILTER_DEFLATE + if(do_compress) + if(H5Pset_deflate(plist_id, 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; + /* 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; - /* Write the data. */ - if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data) < 0) TEST_ERROR; + /* Write the data. */ + if(H5Dwrite(dataset_id , H5T_NATIVE_INT, space_id, 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 + /* 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 - /* Open the file */ - if((file_id = H5Fopen("set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR; + /* Open the file */ + if((file_id = 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; + /* Open the dataset */ + if((dataset_id = H5Dopen2(file_id , "Dataset2", H5P_DEFAULT)) < 0) TEST_ERROR; - /* Set new dimensions for the array. */ - if(H5Dset_extent(dataset_id, dims_new) < 0) TEST_ERROR; + /* Set new dimensions for the array. */ + if(H5Dset_extent(dataset_id, dims_new) < 0) TEST_ERROR; - /* Get the space. */ - if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR; + /* Get the space. */ + if((space_id = H5Dget_space(dataset_id)) < 0) TEST_ERROR; - /* Get dimensions. */ - if(H5Sget_simple_extent_dims(space_id, dims_out, NULL) < 0) TEST_ERROR; + /* Get dimensions. */ + if(H5Sget_simple_extent_dims(space_id, 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; + /* Read the new dataset. */ + if(H5Dread(dataset_id, 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; + /* 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 - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Set new dimensions for the array; expand it again + *------------------------------------------------------------------------- + */ - /* Set new dimensions for the array. */ - if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR; + /* Set new dimensions for the array. */ + if (H5Dset_extent( dataset_id , dims ) < 0) TEST_ERROR; - /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR; + /* Get the space. */ + if ((space_id = H5Dget_space( dataset_id )) < 0) TEST_ERROR; - /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL ) < 0) TEST_ERROR; + /* Get dimensions. */ + if (H5Sget_simple_extent_dims( space_id, 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; + /* Read the new dataset. */ + if (H5Dread( dataset_id, 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; - } - else { - if ( buf2[i][j] != data[i][j] ) 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; + } + else { + if ( buf2[i][j] != data[i][j] ) TEST_ERROR; + } } } - } - /*------------------------------------------------------------------------- - * Close/release resources - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * Close/release resources + *------------------------------------------------------------------------- + */ - H5Dclose( dataset_id ); - H5Sclose( space_id ); + H5Dclose( dataset_id ); + H5Sclose( space_id ); - H5Fclose( file_id ); + H5Fclose( file_id ); - PASSED(); + PASSED(); +#ifdef H5_HAVE_FILTER_DEFLATE + } /* end for */ +#endif /* H5_HAVE_FILTER_DEFLATE */ puts("All set_extent tests passed."); return 0; |