diff options
-rw-r--r-- | test/set_extent.c | 577 |
1 files changed, 351 insertions, 226 deletions
diff --git a/test/set_extent.c b/test/set_extent.c index e92124e..47a6ce5 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -30,6 +30,13 @@ *------------------------------------------------------------------------- */ + +#define FILE_NAME1 "set_extent1.h5" +#define FILE_NAME2 "set_extent2.h5" +#define FILE_NAME3 "set_extent3.h5" +#define FILE_NAME4 "set_extent4.h5" +#define FILE_NAME5 "set_extent5.h5" + #define RANK1 1 #define RANK2 2 #define RANK3 3 @@ -275,13 +282,12 @@ error: return -1; } - /*------------------------------------------------------------------------- - * test usage with a 2D rank + * test usage with a 1D rank *------------------------------------------------------------------------- */ -static int test_rank2( hbool_t do_compress, +static int test_rank1( hbool_t do_compress, hbool_t do_fill_value, hbool_t set_istore_k, H5D_fill_time_t fill_time) @@ -292,17 +298,17 @@ static int test_rank2( hbool_t do_compress, hid_t sid=-1; hid_t dcpl=-1; hid_t fcpl; - hsize_t dims_o[RANK2] = {DIM0,DIM1}; /* original dimensions */ - hsize_t dims_s[RANK2] = {DIMS0,DIMS1}; /* shrinking dimensions */ - hsize_t dims_e[RANK2] = {DIME0,DIME1}; /* extended dimensions */ - hsize_t dims_c[RANK2] = {2,2}; /* chunk dimensions */ - hsize_t dims_r[RANK2]; /* read dimensions */ - hsize_t maxdims[RANK2] = {H5S_UNLIMITED,H5S_UNLIMITED}; - int buf_o[DIM0][DIM1]; - int buf_s[DIMS0][DIMS1]; - int buf_e[DIME0][DIME1]; - int buf_r[DIM0][DIM1]; - int i, j; + hsize_t dims_o[RANK1] = {DIM0}; /* original dimensions */ + hsize_t dims_s[RANK1] = {DIMS0}; /* shrinking dimensions */ + hsize_t dims_e[RANK1] = {DIME0}; /* extended dimensions */ + hsize_t dims_c[RANK1] = {2}; /* chunk dimensions */ + hsize_t dims_r[RANK1]; /* read dimensions */ + hsize_t maxdims[RANK1] = {H5S_UNLIMITED}; + int buf_o[DIM0]; + int buf_s[DIMS0]; + int buf_e[DIME0]; + int buf_r[DIM0]; + int i; int fillvalue = 1; int comp_value; @@ -318,10 +324,8 @@ static int test_rank2( hbool_t do_compress, for( i = 0; i < DIM0; i++ ) { - for( j = 0; j < DIM1; j++ ) - { - buf_o[i][j] = 2; - } + + buf_o[i] = 2; } /* create a file creation property list */ @@ -340,7 +344,7 @@ static int test_rank2( hbool_t do_compress, } /* create a new file */ - if ((fid = H5Fcreate("set_extent1.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE_NAME1, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) { goto error; } @@ -352,7 +356,7 @@ static int test_rank2( hbool_t do_compress, } /* create the data space with unlimited dimensions. */ - if ((sid = H5Screate_simple(RANK2, dims_o, maxdims)) < 0) + if ((sid = H5Screate_simple(RANK1, dims_o, maxdims)) < 0) { goto error; } @@ -362,7 +366,7 @@ static int test_rank2( hbool_t do_compress, { goto error; } - if (H5Pset_chunk(dcpl, RANK2, dims_c) < 0) + if (H5Pset_chunk(dcpl, RANK1, dims_c) < 0) { goto error; } @@ -396,20 +400,7 @@ static int test_rank2( hbool_t do_compress, } /*------------------------------------------------------------------------- - * Procedure 1 - * a. Write an array AxB. These are the dimensions for creating the dataset - * b. Define a greater array CxD where C > A and D > B - * c. Read data back - * d. Verify if new dimensions are C and D - * e. Verify if data from A to C and B to D is what it is to be expected - * - * original data is - * - * 2 2 2 2 - * 2 2 2 2 - * 2 2 2 2 - * 2 2 2 2 - * + * create, write dataset *------------------------------------------------------------------------- */ @@ -426,16 +417,15 @@ static int test_rank2( hbool_t do_compress, } -#if defined (H5_SET_EXTENT_DEBUG2) +#if defined (H5_SET_EXTENT_DEBUG) printf("\n"); for (i = 0; i < (int)dims_o[0]; i++ ) { - for (j = 0; j < (int)dims_o[1]; j++ ) - { - printf("%d ", buf_o[i][j]); - } - printf("\n"); + + printf("%d ", buf_o[i]); + } + printf("\n"); #endif @@ -447,16 +437,6 @@ static int test_rank2( hbool_t do_compress, /*------------------------------------------------------------------------- * set new dimensions for the array; expand it - * data is now, extended space was initialized with fill value or default value - * - * 2 2 2 2 1 1 1 - * 2 2 2 2 1 1 1 - * 2 2 2 2 1 1 1 - * 2 2 2 2 1 1 1 - * 1 1 1 1 1 1 1 - * 1 1 1 1 1 1 1 - * 1 1 1 1 1 1 1 - * *------------------------------------------------------------------------- */ @@ -485,7 +465,7 @@ static int test_rank2( hbool_t do_compress, /* check dimensions */ - for( i = 0; i < RANK2; i++ ) + for( i = 0; i < RANK1; i++ ) { if (dims_r[i] != dims_e[i]) goto error; @@ -497,16 +477,15 @@ static int test_rank2( hbool_t do_compress, -#if defined (H5_SET_EXTENT_DEBUG2) +#if defined (H5_SET_EXTENT_DEBUG) printf("\n"); for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) - { - printf("%d ", buf_e[i][j]); - } - printf("\n"); + + printf("%d ", buf_e[i]); + } + printf("\n"); #endif @@ -515,22 +494,20 @@ static int test_rank2( hbool_t do_compress, /* compare the read array with the expanded array */ for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) + + if ( i >= DIM0 ) { - if ( i >= DIM0 || j >= DIM1 ) + if(buf_e[i] != comp_value) { - if(buf_e[i][j] != comp_value) - { - printf("buf_e[%d][%d] = %d\n", i, j, buf_e[i][j]); - printf("value = %d\n", comp_value); - goto error; - } + printf("buf_e[%d] = %d\n", i, buf_e[i]); + printf("value = %d\n", comp_value); + goto error; } - else - { - if(buf_e[i][j] != buf_o[i][j]) - goto error; - } + } + else + { + if(buf_e[i] != buf_o[i]) + goto error; } } @@ -538,17 +515,7 @@ static int test_rank2( hbool_t do_compress, /*------------------------------------------------------------------------- - * - * Procedure 2 - * a. Define a smaller array ExF where E < A and F < B - * b. Read data back - * c. Verify if new dimensions are E and F - * d. Verify if data up until E and F is what to be expected - * - * data is now - * - * 2 2 - * 2 2 + * shrink * *------------------------------------------------------------------------- */ @@ -577,7 +544,7 @@ static int test_rank2( hbool_t do_compress, } /* check dimensions */ - for( i = 0; i < RANK2; i++ ) + for( i = 0; i < RANK1; i++ ) { if (dims_r[i] != dims_s[i]) goto error; @@ -598,7 +565,7 @@ static int test_rank2( hbool_t do_compress, goto error; } - if ((fid = H5Fopen( "set_extent1.h5", H5F_ACC_RDWR, H5P_DEFAULT ))<0) + if ((fid = H5Fopen( FILE_NAME1, H5F_ACC_RDWR, H5P_DEFAULT ))<0) { goto error; } @@ -624,16 +591,15 @@ static int test_rank2( hbool_t do_compress, goto error; } -#if defined (H5_SET_EXTENT_DEBUG2) +#if defined (H5_SET_EXTENT_DEBUG) printf("\n"); for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) - { - printf("%d ", buf_s[i][j]); - } - printf("\n"); + + printf("%d ", buf_s[i]); } + printf("\n"); + #endif @@ -642,27 +608,18 @@ static int test_rank2( hbool_t do_compress, /* compare the read array with the shrinked array */ for( i = 0; i < (int)dims_r[0]; i++ ) { - for( j = 0; j < (int)dims_r[1]; j++ ) + + if ( buf_s[i] != buf_o[i] ) { - if ( buf_s[i][j] != buf_o[i][j] ) - { - printf("buf_s[%d][%d] = %d\n", i, j, buf_s[i][j]); - printf("buf_o[%d][%d] = %d\n", i, j, buf_o[i][j]); - goto error; - } - } + printf("buf_s[%d] = %d\n", i, buf_s[i]); + printf("buf_o[%d] = %d\n", i, buf_o[i]); + goto error; + } } /*------------------------------------------------------------------------- - * set new dimensions for the array; expand it back to original size - * data is now, extended space was initialized with fill value or default value - * - * 2 2 1 1 - * 2 2 1 1 - * 1 1 1 1 - * 1 1 1 1 - * + * expand it back to original size *------------------------------------------------------------------------- */ @@ -683,34 +640,34 @@ static int test_rank2( hbool_t do_compress, { goto error; } + + if (H5Sclose(sid) < 0) + { + goto error; + } + /* check dimensions */ - for( i = 0; i < RANK2; i++ ) + for( i = 0; i < RANK1; i++ ) { if (dims_r[i] != dims_o[i]) goto error; } - - /*------------------------------------------------------------------------- - * read - *------------------------------------------------------------------------- - */ - + /* read */ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0) goto error; -#if defined (H5_SET_EXTENT_DEBUG2) +#if defined (H5_SET_EXTENT_DEBUG) printf("\n"); for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) - { - printf("%d ", buf_r[i][j]); - } - printf("\n"); + + printf("%d ", buf_r[i]); + } + printf("\n"); #endif @@ -718,40 +675,72 @@ static int test_rank2( hbool_t do_compress, /* compare the read array with the original array */ for (i = 0; i < (int)dims_r[0]; i++ ) { - for (j = 0; j < (int)dims_r[1]; j++ ) + + if (i >= DIMS0 ) { - if (i >= DIMS0 || j >= DIMS1) + if(buf_r[i] != comp_value) { - if(buf_r[i][j] != comp_value) - { - printf("buf_r[%d][%d] = %d\n", i, j, buf_r[i][j]); - printf("value = %d\n", comp_value); - goto error; - } + printf("buf_r[%d] = %d\n", i, buf_r[i] ); + printf("value = %d\n", comp_value); + goto error; } - else - { - if(buf_r[i][j] != buf_o[i][j]) - goto error; - } + } + else + { + if(buf_r[i] != buf_o[i]) + goto error; } } - + /*------------------------------------------------------------------------- - * close dataset and space + * shrink to 0 + * *------------------------------------------------------------------------- */ + + dims_s[0] = 0; - if (H5Dclose(did) < 0) + /* set new dimensions for the array. */ + if (H5Dset_extent(did , dims_s) < 0) + { + goto error; + } + + /* get the space */ + if ((sid = H5Dget_space(did)) < 0) { goto error; } + + /* get dimensions */ + if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) + { + goto error; + } + if (H5Sclose(sid) < 0) { goto error; } + /* check dimensions */ + for( i = 0; i < RANK1; i++ ) + { + if (dims_r[i] != dims_s[i]) + goto error; + } + + /*------------------------------------------------------------------------- + * close dataset + *------------------------------------------------------------------------- + */ + + if (H5Dclose(did) < 0) + { + goto error; + } + @@ -762,7 +751,7 @@ static int test_rank2( hbool_t do_compress, */ - if ((sid = H5Screate_simple(RANK2, dims_o, maxdims)) < 0) + if ((sid = H5Screate_simple(RANK1, dims_o, maxdims)) < 0) { goto error; } @@ -772,7 +761,6 @@ static int test_rank2( hbool_t do_compress, } /* set new dimensions for the array */ dims_o[ 0 ] = 0; - dims_o[ 1 ] = 0; if (H5Dset_extent( did , dims_o ) < 0) { goto error; @@ -828,11 +816,11 @@ error: } /*------------------------------------------------------------------------- - * test usage with a 1D rank + * test usage with a 2D rank *------------------------------------------------------------------------- */ -static int test_rank1( hbool_t do_compress, +static int test_rank2( hbool_t do_compress, hbool_t do_fill_value, hbool_t set_istore_k, H5D_fill_time_t fill_time) @@ -843,17 +831,17 @@ static int test_rank1( hbool_t do_compress, hid_t sid=-1; hid_t dcpl=-1; hid_t fcpl; - hsize_t dims_o[RANK1] = {DIM0}; /* original dimensions */ - hsize_t dims_s[RANK1] = {DIMS0}; /* shrinking dimensions */ - hsize_t dims_e[RANK1] = {DIME0}; /* extended dimensions */ - hsize_t dims_c[RANK1] = {2}; /* chunk dimensions */ - hsize_t dims_r[RANK1]; /* read dimensions */ - hsize_t maxdims[RANK1] = {H5S_UNLIMITED}; - int buf_o[DIM0]; - int buf_s[DIMS0]; - int buf_e[DIME0]; - int buf_r[DIM0]; - int i; + hsize_t dims_o[RANK2] = {DIM0,DIM1}; /* original dimensions */ + hsize_t dims_s[RANK2] = {DIMS0,DIMS1}; /* shrinking dimensions */ + hsize_t dims_e[RANK2] = {DIME0,DIME1}; /* extended dimensions */ + hsize_t dims_c[RANK2] = {2,2}; /* chunk dimensions */ + hsize_t dims_r[RANK2]; /* read dimensions */ + hsize_t maxdims[RANK2] = {H5S_UNLIMITED,H5S_UNLIMITED}; + int buf_o[DIM0][DIM1]; + int buf_s[DIMS0][DIMS1]; + int buf_e[DIME0][DIME1]; + int buf_r[DIM0][DIM1]; + int i, j; int fillvalue = 1; int comp_value; @@ -869,8 +857,10 @@ static int test_rank1( hbool_t do_compress, for( i = 0; i < DIM0; i++ ) { - - buf_o[i] = 2; + for( j = 0; j < DIM1; j++ ) + { + buf_o[i][j] = 2; + } } /* create a file creation property list */ @@ -889,7 +879,7 @@ static int test_rank1( hbool_t do_compress, } /* create a new file */ - if ((fid = H5Fcreate("set_extent1.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE_NAME2, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) { goto error; } @@ -901,7 +891,7 @@ static int test_rank1( hbool_t do_compress, } /* create the data space with unlimited dimensions. */ - if ((sid = H5Screate_simple(RANK1, dims_o, maxdims)) < 0) + if ((sid = H5Screate_simple(RANK2, dims_o, maxdims)) < 0) { goto error; } @@ -911,7 +901,7 @@ static int test_rank1( hbool_t do_compress, { goto error; } - if (H5Pset_chunk(dcpl, RANK1, dims_c) < 0) + if (H5Pset_chunk(dcpl, RANK2, dims_c) < 0) { goto error; } @@ -945,7 +935,20 @@ static int test_rank1( hbool_t do_compress, } /*------------------------------------------------------------------------- - * create, write dataset + * Procedure 1 + * a. Write an array AxB. These are the dimensions for creating the dataset + * b. Define a greater array CxD where C > A and D > B + * c. Read data back + * d. Verify if new dimensions are C and D + * e. Verify if data from A to C and B to D is what it is to be expected + * + * original data is + * + * 2 2 2 2 + * 2 2 2 2 + * 2 2 2 2 + * 2 2 2 2 + * *------------------------------------------------------------------------- */ @@ -962,15 +965,16 @@ static int test_rank1( hbool_t do_compress, } -#if defined (H5_SET_EXTENT_DEBUG) +#if defined (H5_SET_EXTENT_DEBUG2) printf("\n"); for (i = 0; i < (int)dims_o[0]; i++ ) { - - printf("%d ", buf_o[i]); - + for (j = 0; j < (int)dims_o[1]; j++ ) + { + printf("%d ", buf_o[i][j]); + } + printf("\n"); } - printf("\n"); #endif @@ -982,6 +986,16 @@ static int test_rank1( hbool_t do_compress, /*------------------------------------------------------------------------- * set new dimensions for the array; expand it + * data is now, extended space was initialized with fill value or default value + * + * 2 2 2 2 1 1 1 + * 2 2 2 2 1 1 1 + * 2 2 2 2 1 1 1 + * 2 2 2 2 1 1 1 + * 1 1 1 1 1 1 1 + * 1 1 1 1 1 1 1 + * 1 1 1 1 1 1 1 + * *------------------------------------------------------------------------- */ @@ -1010,7 +1024,7 @@ static int test_rank1( hbool_t do_compress, /* check dimensions */ - for( i = 0; i < RANK1; i++ ) + for( i = 0; i < RANK2; i++ ) { if (dims_r[i] != dims_e[i]) goto error; @@ -1022,15 +1036,16 @@ static int test_rank1( hbool_t do_compress, -#if defined (H5_SET_EXTENT_DEBUG) +#if defined (H5_SET_EXTENT_DEBUG2) printf("\n"); for (i = 0; i < (int)dims_r[0]; i++ ) { - - printf("%d ", buf_e[i]); - + for (j = 0; j < (int)dims_r[1]; j++ ) + { + printf("%d ", buf_e[i][j]); + } + printf("\n"); } - printf("\n"); #endif @@ -1039,20 +1054,22 @@ static int test_rank1( hbool_t do_compress, /* compare the read array with the expanded array */ for (i = 0; i < (int)dims_r[0]; i++ ) { - - if ( i >= DIM0 ) + for (j = 0; j < (int)dims_r[1]; j++ ) { - if(buf_e[i] != comp_value) + if ( i >= DIM0 || j >= DIM1 ) { - printf("buf_e[%d] = %d\n", i, buf_e[i]); - printf("value = %d\n", comp_value); - goto error; + if(buf_e[i][j] != comp_value) + { + printf("buf_e[%d][%d] = %d\n", i, j, buf_e[i][j]); + printf("value = %d\n", comp_value); + goto error; + } } - } - else - { - if(buf_e[i] != buf_o[i]) - goto error; + else + { + if(buf_e[i][j] != buf_o[i][j]) + goto error; + } } } @@ -1060,7 +1077,17 @@ static int test_rank1( hbool_t do_compress, /*------------------------------------------------------------------------- - * shrink + * + * Procedure 2 + * a. Define a smaller array ExF where E < A and F < B + * b. Read data back + * c. Verify if new dimensions are E and F + * d. Verify if data up until E and F is what to be expected + * + * data is now + * + * 2 2 + * 2 2 * *------------------------------------------------------------------------- */ @@ -1089,7 +1116,7 @@ static int test_rank1( hbool_t do_compress, } /* check dimensions */ - for( i = 0; i < RANK1; i++ ) + for( i = 0; i < RANK2; i++ ) { if (dims_r[i] != dims_s[i]) goto error; @@ -1110,7 +1137,7 @@ static int test_rank1( hbool_t do_compress, goto error; } - if ((fid = H5Fopen( "set_extent1.h5", H5F_ACC_RDWR, H5P_DEFAULT ))<0) + if ((fid = H5Fopen( FILE_NAME2, H5F_ACC_RDWR, H5P_DEFAULT ))<0) { goto error; } @@ -1136,15 +1163,16 @@ static int test_rank1( hbool_t do_compress, goto error; } -#if defined (H5_SET_EXTENT_DEBUG) +#if defined (H5_SET_EXTENT_DEBUG2) printf("\n"); for (i = 0; i < (int)dims_r[0]; i++ ) { - - printf("%d ", buf_s[i]); + for (j = 0; j < (int)dims_r[1]; j++ ) + { + printf("%d ", buf_s[i][j]); + } + printf("\n"); } - printf("\n"); - #endif @@ -1153,18 +1181,27 @@ static int test_rank1( hbool_t do_compress, /* compare the read array with the shrinked array */ for( i = 0; i < (int)dims_r[0]; i++ ) { - - if ( buf_s[i] != buf_o[i] ) + for( j = 0; j < (int)dims_r[1]; j++ ) { - printf("buf_s[%d] = %d\n", i, buf_s[i]); - printf("buf_o[%d] = %d\n", i, buf_o[i]); - goto error; - } + if ( buf_s[i][j] != buf_o[i][j] ) + { + printf("buf_s[%d][%d] = %d\n", i, j, buf_s[i][j]); + printf("buf_o[%d][%d] = %d\n", i, j, buf_o[i][j]); + goto error; + } + } } /*------------------------------------------------------------------------- - * expand it back to original size + * set new dimensions for the array; expand it back to original size + * data is now, extended space was initialized with fill value or default value + * + * 2 2 1 1 + * 2 2 1 1 + * 1 1 1 1 + * 1 1 1 1 + * *------------------------------------------------------------------------- */ @@ -1185,28 +1222,39 @@ static int test_rank1( hbool_t do_compress, { goto error; } + + if (H5Sclose(sid) < 0) + { + goto error; + } /* check dimensions */ - for( i = 0; i < RANK1; i++ ) + for( i = 0; i < RANK2; i++ ) { if (dims_r[i] != dims_o[i]) goto error; } - + + /*------------------------------------------------------------------------- + * read + *------------------------------------------------------------------------- + */ + /* read */ if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf_r) < 0) goto error; -#if defined (H5_SET_EXTENT_DEBUG) +#if defined (H5_SET_EXTENT_DEBUG2) printf("\n"); for (i = 0; i < (int)dims_r[0]; i++ ) { - - printf("%d ", buf_r[i]); - + for (j = 0; j < (int)dims_r[1]; j++ ) + { + printf("%d ", buf_r[i][j]); + } + printf("\n"); } - printf("\n"); #endif @@ -1214,41 +1262,75 @@ static int test_rank1( hbool_t do_compress, /* compare the read array with the original array */ for (i = 0; i < (int)dims_r[0]; i++ ) { - - if (i >= DIMS0 ) + for (j = 0; j < (int)dims_r[1]; j++ ) { - if(buf_r[i] != comp_value) + if (i >= DIMS0 || j >= DIMS1) { - printf("buf_r[%d] = %d\n", i, buf_r[i] ); - printf("value = %d\n", comp_value); - goto error; + if(buf_r[i][j] != comp_value) + { + printf("buf_r[%d][%d] = %d\n", i, j, buf_r[i][j]); + printf("value = %d\n", comp_value); + goto error; + } } - } - else - { - if(buf_r[i] != buf_o[i]) - goto error; + else + { + if(buf_r[i][j] != buf_o[i][j]) + goto error; + } } } - - + /*------------------------------------------------------------------------- - * close dataset and space + * shrink to 0 + * *------------------------------------------------------------------------- */ + + dims_s[0] = 0; + dims_s[1] = 0; - if (H5Dclose(did) < 0) + /* set new dimensions for the array. */ + if (H5Dset_extent(did , dims_s) < 0) + { + goto error; + } + + /* get the space */ + if ((sid = H5Dget_space(did)) < 0) + { + goto error; + } + + /* get dimensions */ + if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) { goto error; } + if (H5Sclose(sid) < 0) { goto error; } + /* check dimensions */ + for( i = 0; i < RANK2; i++ ) + { + if (dims_r[i] != dims_s[i]) + goto error; + } - + /*------------------------------------------------------------------------- + * close dataset + *------------------------------------------------------------------------- + */ + + if (H5Dclose(did) < 0) + { + goto error; + } + /*------------------------------------------------------------------------- * test a dataset with non initialized chunks @@ -1256,7 +1338,7 @@ static int test_rank1( hbool_t do_compress, */ - if ((sid = H5Screate_simple(RANK1, dims_o, maxdims)) < 0) + if ((sid = H5Screate_simple(RANK2, dims_o, maxdims)) < 0) { goto error; } @@ -1266,6 +1348,7 @@ static int test_rank1( hbool_t do_compress, } /* set new dimensions for the array */ dims_o[ 0 ] = 0; + dims_o[ 1 ] = 0; if (H5Dset_extent( did , dims_o ) < 0) { goto error; @@ -1321,6 +1404,8 @@ error: } + + /*------------------------------------------------------------------------- * test usage with a 3D rank *------------------------------------------------------------------------- @@ -1388,7 +1473,7 @@ static int test_rank3( hbool_t do_compress, } /* create a new file */ - if ((fid = H5Fcreate("set_extent1.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE_NAME3, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0) { goto error; } @@ -1628,7 +1713,7 @@ static int test_rank3( hbool_t do_compress, goto error; } - if ((fid = H5Fopen( "set_extent1.h5", H5F_ACC_RDWR, H5P_DEFAULT ))<0) + if ((fid = H5Fopen( FILE_NAME3, H5F_ACC_RDWR, H5P_DEFAULT ))<0) { goto error; } @@ -1715,6 +1800,11 @@ static int test_rank3( hbool_t do_compress, { goto error; } + + if (H5Sclose(sid) < 0) + { + goto error; + } /* check dimensions */ for( i = 0; i < RANK3; i++ ) @@ -1773,26 +1863,61 @@ static int test_rank3( hbool_t do_compress, } } - + /*------------------------------------------------------------------------- - * close dataset and space + * shrink to 0 + * *------------------------------------------------------------------------- */ + + dims_s[0] = 0; + dims_s[1] = 0; + dims_s[2] = 0; - if (H5Dclose(did) < 0) + /* set new dimensions for the array. */ + if (H5Dset_extent(did , dims_s) < 0) { goto error; } + + /* get the space */ + if ((sid = H5Dget_space(did)) < 0) + { + goto error; + } + + /* get dimensions */ + if (H5Sget_simple_extent_dims(sid, dims_r, NULL) < 0) + { + goto error; + } + if (H5Sclose(sid) < 0) { goto error; } + /* check dimensions */ + for( i = 0; i < RANK3; i++ ) + { + if (dims_r[i] != dims_s[i]) + goto error; + } - - /*------------------------------------------------------------------------- + /*------------------------------------------------------------------------- + * close dataset + *------------------------------------------------------------------------- + */ + + if (H5Dclose(did) < 0) + { + goto error; + } + + + /*------------------------------------------------------------------------- * test a dataset with non initialized chunks *------------------------------------------------------------------------- */ @@ -1908,7 +2033,7 @@ static int test_external( void ) TESTING("external file use"); /* create a new file */ - if ((fid = H5Fcreate("set_extent2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE_NAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { goto error; } @@ -2269,7 +2394,7 @@ static int test_layouts( H5D_layout_t layout ) /* create a new file */ - if ((fid = H5Fcreate("set_extent3.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(FILE_NAME5, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { goto error; } |