summaryrefslogtreecommitdiffstats
path: root/tools/h5dump/h5dumpgentest.c
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2007-02-12 19:57:44 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2007-02-12 19:57:44 (GMT)
commit319ad4c84b5ef3b7ee3d5ec70b12ed5e5fc3e825 (patch)
tree4699c9e679bbb1abdb819d418bbb669ceac99e5b /tools/h5dump/h5dumpgentest.c
parentaaa8bba35443dd426d281f757eac3aae2e01b0e0 (diff)
downloadhdf5-319ad4c84b5ef3b7ee3d5ec70b12ed5e5fc3e825.zip
hdf5-319ad4c84b5ef3b7ee3d5ec70b12ed5e5fc3e825.tar.gz
hdf5-319ad4c84b5ef3b7ee3d5ec70b12ed5e5fc3e825.tar.bz2
[svn-r13280]
2 tests that were previously incorporated inside the array indices test file were separated from it. These are a test with a dataset with dimensions greater tan 4GB and a test to read by hyperslabs
Diffstat (limited to 'tools/h5dump/h5dumpgentest.c')
-rw-r--r--tools/h5dump/h5dumpgentest.c152
1 files changed, 139 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;
}