diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/tselect.c | 366 |
1 files changed, 0 insertions, 366 deletions
diff --git a/test/tselect.c b/test/tselect.c index 9150b11..011be7c 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -4910,365 +4910,6 @@ test_select_hyper_union(void) HDfree(rbuf); } /* test_select_hyper_union() */ -#ifdef NEW_HYPERSLAB_API -/**************************************************************** -** -** test_select_hyper_union_stagger(): Test basic H5S (dataspace) selection code. -** Tests unions of staggered hyperslabs. (Uses H5Scombine_hyperslab -** and H5Sselect_select instead of H5Sselect_hyperslab) -** -****************************************************************/ -static void -test_select_hyper_union_stagger(void) -{ - hid_t file_id; /* File ID */ - hid_t dset_id; /* Dataset ID */ - hid_t dataspace; /* File dataspace ID */ - hid_t memspace; /* Memory dataspace ID */ - hid_t tmp_space; /* Temporary dataspace ID */ - hid_t tmp2_space; /* Another emporary dataspace ID */ - hsize_t dimsm[2]={7,7}; /* Memory array dimensions */ - hsize_t dimsf[2]={6,5}; /* File array dimensions */ - hsize_t count[2]={3,1}; /* 1st Hyperslab size */ - hsize_t count2[2]={3,1}; /* 2nd Hyperslab size */ - hsize_t count3[2]={2,1}; /* 3rd Hyperslab size */ - hssize_t offset[2]={0,0}; /* 1st Hyperslab offset */ - hssize_t offset2[2]={2,1}; /* 2nd Hyperslab offset */ - hssize_t offset3[2]={4,2}; /* 3rd Hyperslab offset */ - hsize_t count_out[2]={4,2}; /* Hyperslab size in memory */ - hssize_t offset_out[2]={0,3}; /* Hyperslab offset in memory */ - int data[6][5]; /* Data to write */ - int data_out[7][7]; /* Data read in */ - int input_loc[8][2]={{0,0}, - {1,0}, - {2,0}, - {2,1}, - {3,1}, - {4,1}, - {4,2}, - {5,2}}; - int output_loc[8][2]={{0,3}, - {0,4}, - {1,3}, - {1,4}, - {2,3}, - {2,4}, - {3,3}, - {3,4}}; - int dsetrank=2; /* File Dataset rank */ - int memrank=2; /* Memory Dataset rank */ - int i,j; /* Local counting variables */ - herr_t error; - hsize_t stride[2]={1,1}; - hsize_t block[2]={1,1}; - - /* Initialize data to write */ - for(i=0; i<6; i++) - for(j=0; j<5; j++) - data[i][j] = j*10 + i; - - /* Create file */ - file_id=H5Fcreate(FILENAME,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); - CHECK(file_id, FAIL, "H5Fcreate"); - - /* Create File Dataspace */ - dataspace=H5Screate_simple(dsetrank,dimsf,NULL); - CHECK(dataspace, FAIL, "H5Screate_simple"); - - /* Create File Dataset */ - dset_id=H5Dcreate2(file_id,"IntArray",H5T_NATIVE_INT,dataspace,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset_id, FAIL, "H5Dcreate2"); - - /* Write File Dataset */ - error=H5Dwrite(dset_id,H5T_NATIVE_INT,dataspace,dataspace,H5P_DEFAULT,data); - CHECK(error, FAIL, "H5Dwrite"); - - /* Close things */ - error=H5Sclose(dataspace); - CHECK(error, FAIL, "H5Sclose"); - error = H5Dclose(dset_id); - CHECK(error, FAIL, "H5Dclose"); - error = H5Fclose(file_id); - CHECK(error, FAIL, "H5Fclose"); - - /* Initialize intput buffer */ - memset(data_out, 0, 7 * 7 * sizeof(int)); - - /* Open file */ - file_id = H5Fopen(FILENAME, H5F_ACC_RDONLY, H5P_DEFAULT); - CHECK(file_id, FAIL, "H5Fopen"); - - /* Open dataset */ - dset_id = H5Dopen2(file_id, "IntArray", H5P_DEFAULT); - CHECK(dset_id, FAIL, "H5Dopen2"); - - /* Get the dataspace */ - dataspace = H5Dget_space(dset_id); - CHECK(dataspace, FAIL, "H5Dget_space"); - - /* Select the hyperslabs */ - error = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, stride, count, block); - CHECK(error, FAIL, "H5Sselect_hyperslab"); - tmp_space = H5Scombine_hyperslab(dataspace, H5S_SELECT_OR, offset2, stride, count2, block); - CHECK(tmp_space, FAIL, "H5Scombine_hyperslab"); - - /* Copy the file dataspace and select hyperslab */ - tmp2_space = H5Scopy(dataspace); - CHECK(tmp2_space, FAIL, "H5Scopy"); - error=H5Sselect_hyperslab(tmp2_space,H5S_SELECT_SET,offset3,stride,count3,block); - CHECK(error, FAIL, "H5Sselect_hyperslab"); - - /* Combine the copied dataspace with the temporary dataspace */ - error=H5Sselect_select(tmp_space,H5S_SELECT_OR,tmp2_space); - CHECK(error, FAIL, "H5Sselect_select"); - - /* Create Memory Dataspace */ - memspace=H5Screate_simple(memrank,dimsm,NULL); - CHECK(memspace, FAIL, "H5Screate_simple"); - - /* Select hyperslab in memory */ - error=H5Sselect_hyperslab(memspace,H5S_SELECT_SET,offset_out,stride,count_out,block); - CHECK(error, FAIL, "H5Sselect_hyperslab"); - - /* Read File Dataset */ - error=H5Dread(dset_id,H5T_NATIVE_INT,memspace,tmp_space,H5P_DEFAULT,data_out); - CHECK(error, FAIL, "H5Dread"); - - /* Verify input data */ - for(i=0; i<8; i++) { - if(data[input_loc[i][0]][input_loc[i][1]]!=data_out[output_loc[i][0]][output_loc[i][1]]) { - printf("input data #%d is wrong!\n",i); - printf("input_loc=[%d][%d]\n",input_loc[i][0],input_loc[i][1]); - printf("output_loc=[%d][%d]\n",output_loc[i][0],output_loc[i][1]); - printf("data=%d\n",data[input_loc[i][0]][input_loc[i][1]]); - TestErrPrintf("data_out=%d\n",data_out[output_loc[i][0]][output_loc[i][1]]); - } /* end if */ - } /* end for */ - - /* Close things */ - error=H5Sclose(tmp2_space); - CHECK(error, FAIL, "H5Sclose"); - error=H5Sclose(tmp_space); - CHECK(error, FAIL, "H5Sclose"); - error=H5Sclose(dataspace); - CHECK(error, FAIL, "H5Sclose"); - error=H5Sclose(memspace); - CHECK(error, FAIL, "H5Sclose"); - error=H5Dclose(dset_id); - CHECK(error, FAIL, "H5Dclose"); - error=H5Fclose(file_id); - CHECK(error, FAIL, "H5Fclose"); -} - -/**************************************************************** -** -** test_select_hyper_union_3d(): Test basic H5S (dataspace) selection code. -** Tests unions of hyperslabs in 3-D (Uses H5Scombine_hyperslab -** and H5Scombine_select instead of H5Sselect_hyperslab) -** -****************************************************************/ -static void -test_select_hyper_union_3d(void) -{ - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t tmp_space; /* Temporary Dataspace ID */ - hid_t tmp2_space; /* Another temporary Dataspace ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {SPACE4_DIM1, SPACE4_DIM2, SPACE4_DIM3}; - hsize_t dims3[] = {SPACE3_DIM1, SPACE3_DIM2}; - hsize_t start[SPACE1_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE1_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ - struct row_list { - size_t z; - size_t y; - size_t x; - size_t l; - } rows[]= { /* Array of x,y,z coordinates & length for each row written from memory */ - {0,0,0,6}, /* 1st face of 3-D object */ - {0,1,0,6}, - {0,2,0,6}, - {0,3,0,6}, - {0,4,0,6}, - {1,0,0,6}, /* 2nd face of 3-D object */ - {1,1,0,6}, - {1,2,0,6}, - {1,3,0,6}, - {1,4,0,6}, - {2,0,0,6}, /* 3rd face of 3-D object */ - {2,1,0,10}, - {2,2,0,10}, - {2,3,0,10}, - {2,4,0,10}, - {2,5,2,8}, - {2,6,2,8}, - {3,0,0,6}, /* 4th face of 3-D object */ - {3,1,0,10}, - {3,2,0,10}, - {3,3,0,10}, - {3,4,0,10}, - {3,5,2,8}, - {3,6,2,8}, - {4,0,0,6}, /* 5th face of 3-D object */ - {4,1,0,10}, - {4,2,0,10}, - {4,3,0,10}, - {4,4,0,10}, - {4,5,2,8}, - {4,6,2,8}, - {5,1,2,8}, /* 6th face of 3-D object */ - {5,2,2,8}, - {5,3,2,8}, - {5,4,2,8}, - {5,5,2,8}, - {5,6,2,8}, - {6,1,2,8}, /* 7th face of 3-D object */ - {6,2,2,8}, - {6,3,2,8}, - {6,4,2,8}, - {6,5,2,8}, - {6,6,2,8}, - {7,1,2,8}, /* 8th face of 3-D object */ - {7,2,2,8}, - {7,3,2,8}, - {7,4,2,8}, - {7,5,2,8}, - {7,6,2,8}}; - uint8_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf, /* temporary buffer pointer */ - *tbuf2; /* temporary buffer pointer */ - int i,j,k; /* Counters */ - herr_t ret; /* Generic return value */ - hsize_t npoints; /* Number of elements in selection */ - - /* Output message about test being performed */ - MESSAGE(5, ("Testing Hyperslab Selection Functions with unions of 3-D hyperslabs\n")); - - /* Allocate write & read buffers */ - wbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE4_DIM1 * SPACE4_DIM2 * SPACE4_DIM3); - CHECK(wbuf, NULL, "HDmalloc"); - rbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE3_DIM1 * SPACE3_DIM2); - CHECK(rbuf, NULL, "HDcalloc"); - - /* Initialize write buffer */ - for(i=0, tbuf=wbuf; i<SPACE4_DIM1; i++) - for(j=0; j<SPACE4_DIM2; j++) - for(k=0; k<SPACE4_DIM3; k++) - *tbuf++=(uint8_t)((((i*SPACE4_DIM2)+j)*SPACE4_DIM3)+k); - - /* Create file */ - fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - CHECK(fid1, FAIL, "H5Fcreate"); - -/* Test case of two blocks which overlap corners and must be split */ - /* Create dataspace for dataset on disk */ - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - CHECK(sid1, FAIL, "H5Screate_simple"); - - /* Create dataspace for writing buffer */ - sid2 = H5Screate_simple(SPACE4_RANK, dims2, NULL); - CHECK(sid2, FAIL, "H5Screate_simple"); - - /* Select 2x15x13 hyperslab for disk dataset */ - start[0]=1; start[1]=0; start[2]=0; - stride[0]=1; stride[1]=1; stride[2]=1; - count[0]=2; count[1]=15; count[2]=13; - block[0]=1; block[1]=1; block[2]=1; - ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,stride,count,block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); - - /* Select 5x5x6 hyperslab for memory dataset */ - start[0]=0; start[1]=0; start[2]=0; - stride[0]=1; stride[1]=1; stride[2]=1; - count[0]=5; count[1]=5; count[2]=6; - block[0]=1; block[1]=1; block[2]=1; - ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); - - /* Union overlapping 15x20 hyperslab for memory dataset (forming a irregularly shaped region) */ - start[0]=2; start[1]=1; start[2]=2; - stride[0]=1; stride[1]=1; stride[2]=1; - count[0]=6; count[1]=6; count[2]=8; - block[0]=1; block[1]=1; block[2]=1; - tmp_space = H5Scombine_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block); - CHECK(tmp_space, FAIL, "H5Sselect_hyperslab"); - - /* Combine dataspaces and create new dataspace */ - tmp2_space = H5Scombine_select(sid2,H5S_SELECT_OR,tmp_space); - CHECK(tmp2_space, FAIL, "H5Scombin_select"); - - npoints = (hsize_t)H5Sget_select_npoints(tmp2_space); - VERIFY(npoints, 15*26, "H5Sget_select_npoints"); - - /* Create a dataset */ - dataset = H5Dcreate2(fid1, SPACE1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dataset, FAIL, "H5Dcreate2"); - - /* Write selection to disk */ - ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,tmp2_space,sid1,H5P_DEFAULT,wbuf); - CHECK(ret, FAIL, "H5Dwrite"); - - /* Close temporary dataspaces */ - ret = H5Sclose(tmp_space); - CHECK(ret, FAIL, "H5Sclose"); - ret = H5Sclose(tmp2_space); - CHECK(ret, FAIL, "H5Sclose"); - - /* Close memory dataspace */ - ret = H5Sclose(sid2); - CHECK(ret, FAIL, "H5Sclose"); - - /* Create dataspace for reading buffer */ - sid2 = H5Screate_simple(SPACE3_RANK, dims3, NULL); - CHECK(sid2, FAIL, "H5Screate_simple"); - - /* Select 15x26 hyperslab for reading memory dataset */ - start[0]=0; start[1]=0; - stride[0]=1; stride[1]=1; - count[0]=15; count[1]=26; - block[0]=1; block[1]=1; - ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); - - /* Read selection from disk */ - ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,H5P_DEFAULT,rbuf); - CHECK(ret, FAIL, "H5Dread"); - - /* Compare data read with data written out */ - for(i=0,tbuf2=rbuf; i<(int)(sizeof(rows)/sizeof(struct row_list)); i++) { - tbuf=wbuf+(rows[i].z*SPACE4_DIM3*SPACE4_DIM2)+(rows[i].y*SPACE4_DIM3)+rows[i].x; - for(j=0; j<(int)rows[i].l; j++, tbuf++, tbuf2++) { - if(*tbuf!=*tbuf2) - TestErrPrintf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%d, *tbuf2=%d\n",__LINE__,i,j,(int)*tbuf,(int)*tbuf2); - } /* end for */ - } /* end for */ - - /* Close memory dataspace */ - ret = H5Sclose(sid2); - CHECK(ret, FAIL, "H5Sclose"); - - /* Close disk dataspace */ - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); - - /* Close Dataset */ - ret = H5Dclose(dataset); - CHECK(ret, FAIL, "H5Dclose"); - - /* Close file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); - - /* Free memory buffers */ - HDfree(wbuf); - HDfree(rbuf); -} /* test_select_hyper_union_3d() */ -#endif /* NEW_HYPERSLAB_API */ - /**************************************************************** ** ** test_select_hyper_and_2d(): Test basic H5S (dataspace) selection code. @@ -6222,9 +5863,6 @@ test_select_point_chunk(void) herr_t ret; /* Generic return value */ unsigned *data_out; /* output buffer */ -#ifdef LATER - unsigned *tmpdata_out; /* output buffer */ -#endif /* LATER */ hsize_t start[SPACE7_RANK]; /* hyperslab offset */ hsize_t count[SPACE7_RANK]; /* size of the hyperslab */ @@ -13669,10 +13307,6 @@ test_select(void) test_select_hyper_offset2();/* Test more selection offset code with hyperslabs */ test_select_point_offset(); /* Test selection offset code with elements */ test_select_hyper_union(); /* Test hyperslab union code */ -#ifdef NEW_HYPERSLAB_API - test_select_hyper_union_stagger(); /* Test hyperslab union code for staggered slabs */ - test_select_hyper_union_3d(); /* Test hyperslab union code for 3-D dataset */ -#endif /* NEW_HYPERSLAB_API */ test_select_hyper_and_2d(); /* Test hyperslab intersection (AND) code for 2-D dataset */ test_select_hyper_xor_2d(); /* Test hyperslab XOR code for 2-D dataset */ test_select_hyper_notb_2d(); /* Test hyperslab NOTB code for 2-D dataset */ |