diff options
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 152 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 6 |
2 files changed, 145 insertions, 13 deletions
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 9130eae..2a955b4 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -83,8 +83,8 @@ #define FILE53 "textlink.h5" #define FILE54 "tudlink.h5" #define FILE55 "tbinary.h5" - - +#define FILE56 "tbigdims.h5" +#define FILE57 "thyperslab.h5" /*------------------------------------------------------------------------- * prototypes @@ -5360,7 +5360,7 @@ static void gent_string(void) /*------------------------------------------------------------------------- * Function: gent_aindices * - * Purpose: make several datasets for the array indices tests + * Purpose: make several datasets for the array indices and subsetting tests * *------------------------------------------------------------------------- */ @@ -5372,12 +5372,10 @@ static void gent_aindices(void) hsize_t dims2[2] = {10,10}; hsize_t dims3[3] = {2,10,10}; hsize_t dims4[4] = {2,2,10,10}; - hsize_t dims5[2] = {32,4097}; /* big enough data size to force a second stripmine read */ int buf1[100]; int buf2[10][10]; int buf3[2][10][10]; int buf4[2][2][10][10]; - double *buf5; int i, j, k, l, n, ret; for (i=n=0; i<100; i++){ @@ -5406,10 +5404,6 @@ static void gent_aindices(void) } } - buf5 = malloc(32 * 4097 * sizeof(double) ); - for (i = 0; i < 32 * 4097; i++) - buf5[i] = 1; - /* create a file */ fid = H5Fcreate(FILE50, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); assert(fid>=0); @@ -5422,7 +5416,6 @@ static void gent_aindices(void) write_dset(fid,2,dims2,"2d",H5T_NATIVE_INT,buf2); write_dset(fid,3,dims3,"3d",H5T_NATIVE_INT,buf3); write_dset(fid,4,dims4,"4d",H5T_NATIVE_INT,buf4); - write_dset(fid,2,dims5,"stripmine",H5T_NATIVE_DOUBLE,buf5); /*------------------------------------------------------------------------- * test with group indentation @@ -5448,9 +5441,9 @@ static void gent_aindices(void) ret=H5Fclose(fid); assert(ret>=0); - free(buf5); } + /*------------------------------------------------------------------------- * Function: gent_longlinks * @@ -5501,8 +5494,6 @@ static void gent_longlinks(void) HDfree(objname); } - - /*------------------------------------------------------------------------- * Function: gent_ldouble * @@ -5635,6 +5626,139 @@ gent_binary(void) } /*------------------------------------------------------------------------- + * Function: gen_bigdims + * + * Purpose: generate a dataset with dimensions greater than 4GB + * and write one hyperslab on the boundary + * + *------------------------------------------------------------------------- + */ +#define GB4LL ((unsigned long_long) 4*1024*1024*1024) +#define DIM_4GB (GB4LL + 10) + +static void gent_bigdims(void) +{ + hid_t fid; + hid_t did; + hid_t f_sid; + hid_t m_sid; + hid_t tid; + hid_t dcpl; + hsize_t dims[1]={DIM_4GB}; /* dataset dimensions */ + hsize_t chunk_dims[1]={1024}; /* chunk dimensions */ + hsize_t hs_start[1]; + hsize_t hs_size[1]; /* hyperslab dimensions */ + size_t size; + char fillvalue=-1; + char *buf=NULL; + hsize_t i; + char c; + size_t nelmts; + int ret; + + /* create a file */ + fid = H5Fcreate(FILE56, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + assert(fid>=0); + + /* create dataset */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) + goto out; + if (H5Pset_fill_value(dcpl, H5T_NATIVE_CHAR, &fillvalue)<0) + goto out; + if (H5Pset_chunk(dcpl, 1, chunk_dims)<0) + goto out; + if ((f_sid = H5Screate_simple(1,dims,NULL))<0) + goto out; + if ((did = H5Dcreate(fid,"dset4gb",H5T_NATIVE_CHAR,f_sid,dcpl))<0) + goto out; + if ((tid = H5Dget_type(did))<0) + goto out; + if ((size = H5Tget_size(tid))<=0) + goto out; + + /* select an hyperslab */ + nelmts = 20; + hs_start[0] = GB4LL - 10; + hs_size[0] = nelmts; + + if ((m_sid = H5Screate_simple(1, hs_size, hs_size))<0) + goto out; + + buf=(char *) malloc((unsigned)(nelmts*size)); + + for (i=0, c=0; i<nelmts; i++, c++) + { + buf[i] = c; + } + + if (H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size,NULL)<0) + goto out; + if (H5Dwrite (did,H5T_NATIVE_CHAR,m_sid,f_sid,H5P_DEFAULT,buf)<0) + goto out; + + + free(buf); + buf=NULL; + + /* close */ + if(H5Sclose(f_sid)<0) + goto out; + if(H5Sclose(m_sid)<0) + goto out; + if(H5Pclose(dcpl)<0) + goto out; + if(H5Dclose(did)<0) + goto out; + + ret=H5Fclose(fid); + assert(ret>=0); + + return; + +out: + printf("Error.....\n"); + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Sclose(f_sid); + H5Sclose(m_sid); + H5Dclose(did); + H5Fclose(fid); + } H5E_END_TRY; + return; + +} +/*------------------------------------------------------------------------- + * Function: gent_hyperslab + * + * Purpose: make a dataset for hyperslab read + * + *------------------------------------------------------------------------- + */ +static void gent_hyperslab(void) +{ + hid_t fid; /* file id */ + hsize_t dims[2] = {32,4097}; /* big enough data size to force a second stripmine read */ + double *buf; + int i, ret; + + buf = malloc(32 * 4097 * sizeof(double) ); + for (i = 0; i < 32 * 4097; i++) + buf[i] = 1; + + /* create a file */ + fid = H5Fcreate(FILE57, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + assert(fid>=0); + + write_dset(fid,2,dims,"stripmine",H5T_NATIVE_DOUBLE,buf); + + ret=H5Fclose(fid); + assert(ret>=0); + + free(buf); +} + + +/*------------------------------------------------------------------------- * Function: main * *------------------------------------------------------------------------- @@ -5697,6 +5821,8 @@ int main(void) gent_longlinks(); gent_ldouble(); gent_binary(); + gent_bigdims(); + gent_hyperslab(); return 0; } diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 1edc490..54d4311 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -343,6 +343,12 @@ TOOLTEST tbin4.ddl -d double -o out4.bin -b FILE tbinary.h5 # test for dataset region references TOOLTEST tregref.ddl tdatareg.h5 +# dimensions over 4GB, print boundary +TOOLTEST tbigdims.ddl -d dset4gb -s 4294967284 -c 22 tbigdims.h5 + +# hyperslab read +TOOLTEST thyperslab.ddl thyperslab.h5 + if test $nerrors -eq 0 ; then echo "All $DUMPER tests passed." fi |