summaryrefslogtreecommitdiffstats
path: root/tools/testfiles/h5dumptst.c
diff options
context:
space:
mode:
authorPaul Harten <pharten@ncsa.uiuc.edu>1999-02-01 23:14:38 (GMT)
committerPaul Harten <pharten@ncsa.uiuc.edu>1999-02-01 23:14:38 (GMT)
commitff7883566f95178ce4ce60a2c649a4000be2938d (patch)
tree6eea9b5c07f646be0d97d11f454f66f744f053c6 /tools/testfiles/h5dumptst.c
parent224b6224fbf43f5c11cddc4b77f8ea046873f8d4 (diff)
downloadhdf5-ff7883566f95178ce4ce60a2c649a4000be2938d.zip
hdf5-ff7883566f95178ce4ce60a2c649a4000be2938d.tar.gz
hdf5-ff7883566f95178ce4ce60a2c649a4000be2938d.tar.bz2
[svn-r1046] Purpose:
New feature Solution: Modified h5dumptst.c to generate more single dimension datasets of H5T_STRING type held in file tstr2.h5. Platform tested: Solaris2.5
Diffstat (limited to 'tools/testfiles/h5dumptst.c')
-rw-r--r--tools/testfiles/h5dumptst.c177
1 files changed, 172 insertions, 5 deletions
diff --git a/tools/testfiles/h5dumptst.c b/tools/testfiles/h5dumptst.c
index 57d74ba..9dc078b 100644
--- a/tools/testfiles/h5dumptst.c
+++ b/tools/testfiles/h5dumptst.c
@@ -3,6 +3,7 @@
*/
#include <limits.h>
#include "hdf5.h"
+#include <H5private.h>
#define FILE1 "tgroup.h5"
#define FILE2 "tdset.h5"
@@ -17,6 +18,7 @@
#define FILE11 "tloop2.h5"
#define FILE12 "tmany.h5"
#define FILE13 "tstr.h5"
+#define FILE14 "tstr2.h5"
static void test_group(void) {
hid_t fid, group;
@@ -463,7 +465,7 @@ typedef struct {
dset5_t dset5[10];
int i, ndims;
-const int perm[2];
+const int perm[2]={0,1};
size_t dim[2];
hsize_t sdim, maxdim;
@@ -811,9 +813,7 @@ const int perm[4] = {0,1,2,3}; /* the 0'th and the 3'rd indices are permuted */
H5Tinsert_array(type, "b_array", HOFFSET(dset1_t, b), 4, dim, perm, H5T_IEEE_F64BE);
H5Tinsert_array(type, "c_array", HOFFSET(dset1_t, c), 4, dim, perm, H5T_IEEE_F64BE);
-/*
H5Tcommit(group, "type1", type);
-*/
/* dset1 */
sdim = 6;
@@ -1055,6 +1055,174 @@ size_t mdims[2];
H5Fclose(fid);
}
+/*
+ /
+ / / | \ \ \
+ g1 g2 g3 g4 g5 g6
+ | | | | \ \
+ string1 string3 string5
+ string2 string4 string6
+*/
+
+static void test_str2(void) {
+hid_t fid, group, attr, dataset, space, space2, mem_space, hyper_space, type;
+hid_t fxdlenstr, fxdlenstr2, memtype;
+hsize_t dims[1], size[1], start[1], stride[1], count[1], block[1];
+
+int lenstr = 50;
+int lenstr2 = 11;
+int i, j;
+int i0, i1, i2, i3;
+char buf[lenstr+10];
+char buf2[3*lenstr2];
+hsize_t sdim, maxdim;
+
+ fid = H5Fcreate(FILE14, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ fxdlenstr = H5Tcopy(H5T_C_S1);
+ H5Tset_size(fxdlenstr, lenstr);
+ H5Tset_cset(fxdlenstr, H5T_CSET_ASCII);
+ H5Tset_strpad(fxdlenstr, H5T_STR_NULLTERM);
+
+ memtype = H5Tcopy(H5T_C_S1);
+ H5Tset_size(memtype, lenstr);
+ H5Tset_cset(memtype, H5T_CSET_ASCII);
+ H5Tset_strpad(memtype, H5T_STR_NULLTERM);
+
+ sdim = 10;
+ size[0] = sdim;
+ space = H5Screate_simple(1, size, NULL);
+ size[0] = 1;
+ mem_space = H5Screate_simple(1,size,NULL);
+ hyper_space = H5Scopy(space);
+
+ /* dset1 */
+
+ group = H5Gcreate (fid, "/g1", 0);
+ dataset = H5Dcreate(group, "dset1", fxdlenstr, space, H5P_DEFAULT);
+
+ /* add attributes to dset1 */
+
+ fxdlenstr2 = H5Tcopy(H5T_C_S1);
+ H5Tset_size(fxdlenstr2, lenstr2);
+ H5Tset_cset(fxdlenstr2, H5T_CSET_ASCII);
+ H5Tset_strpad(fxdlenstr2, H5T_STR_NULLTERM);
+
+ dims[0] = 3;
+ space2 = H5Screate_simple(1, dims, NULL);
+ attr = H5Acreate (dataset, "attr1", fxdlenstr2, space2, H5P_DEFAULT);
+ sprintf(&(buf2[0*lenstr2]), "0123456789");
+ sprintf(&(buf2[1*lenstr2]), "abcdefghij");
+ sprintf(&(buf2[2*lenstr2]), "ABCDEFGHIJ");
+ H5Awrite(attr, fxdlenstr2, buf2);
+ H5Sclose(space2);
+ H5Tclose(fxdlenstr2);
+ H5Aclose(attr);
+
+ stride[0]=1;
+ count[0]=1;
+ block[0]=1;
+
+ for (i = 0; i < sdim; i++) {
+ start[0] = i;
+ sprintf(buf,"This is row %1d of type H5T_STR_NULLTERM of",i);
+ H5Tset_size(memtype, HDstrlen(buf)+1);
+ H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
+ H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf);
+ }
+ H5Dclose(dataset);
+ H5Gclose(group);
+
+ group = H5Gcreate (fid, "/g2", 0);
+ dataset = H5Dcreate(group, "dset2", fxdlenstr, space, H5P_DEFAULT);
+
+ for (i = 0; i < sdim; i++) {
+ start[0] = i;
+ sprintf(buf,"This is row %1d of type H5T_STR_NULLTERM of string array",i);
+ H5Tset_size(memtype, HDstrlen(buf)+1);
+ H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
+ H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf);
+ }
+ H5Dclose(dataset);
+ H5Gclose(group);
+
+
+ H5Tclose(fxdlenstr);
+ fxdlenstr = H5Tcopy(H5T_C_S1);
+ H5Tset_size(fxdlenstr, lenstr);
+ H5Tset_cset(fxdlenstr, H5T_CSET_ASCII);
+ H5Tset_strpad(fxdlenstr, H5T_STR_NULLPAD);
+
+ group = H5Gcreate (fid, "/g3", 0);
+ dataset = H5Dcreate(group, "dset3", fxdlenstr, space, H5P_DEFAULT);
+
+ for (i = 0; i < sdim; i++) {
+ start[0] = i;
+ sprintf(buf,"This is row %1d of type H5T_STR_NULLPAD of",i);
+ H5Tset_size(memtype, HDstrlen(buf)+1);
+ H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
+ H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf);
+ }
+ H5Dclose(dataset);
+ H5Gclose(group);
+
+
+ group = H5Gcreate (fid, "/g4", 0);
+ dataset = H5Dcreate(group, "dset4", fxdlenstr, space, H5P_DEFAULT);
+
+ for (i = 0; i < sdim; i++) {
+ start[0] = i;
+ sprintf(buf,"This is row %1d of type H5T_STR_NULLPAD of string array",i);
+ H5Tset_size(memtype, HDstrlen(buf)+1);
+ H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
+ H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf);
+ }
+ H5Dclose(dataset);
+ H5Gclose(group);
+
+ H5Tclose(fxdlenstr);
+ fxdlenstr = H5Tcopy(H5T_C_S1);
+ H5Tset_size(fxdlenstr, lenstr);
+ H5Tset_cset(fxdlenstr, H5T_CSET_ASCII);
+ H5Tset_strpad(fxdlenstr, H5T_STR_SPACEPAD);
+
+ group = H5Gcreate (fid, "/g5", 0);
+ dataset = H5Dcreate(group, "dset5", fxdlenstr, space, H5P_DEFAULT);
+
+ for (i = 0; i < sdim; i++) {
+ start[0] = i;
+ sprintf(buf,"This is row %1d of type H5T_STR_SPACEPAD of",i);
+ H5Tset_size(memtype, HDstrlen(buf)+1);
+ H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
+ H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf);
+ }
+ H5Dclose(dataset);
+ H5Gclose(group);
+
+
+ group = H5Gcreate (fid, "/g6", 0);
+ dataset = H5Dcreate(group, "dset6", fxdlenstr, space, H5P_DEFAULT);
+
+ for (i = 0; i < sdim; i++) {
+ start[0] = i;
+ sprintf(buf,"This is row %1d of type H5T_STR_SPACEPAD of string array",i);
+ H5Tset_size(memtype, HDstrlen(buf)+1);
+ H5Sselect_hyperslab(hyper_space, H5S_SELECT_SET, start, stride, count, block);
+ H5Dwrite(dataset, memtype, mem_space, hyper_space, H5P_DEFAULT, buf);
+ }
+ H5Dclose(dataset);
+ H5Gclose(group);
+
+ H5Tclose(fxdlenstr);
+ H5Tclose(memtype);
+ H5Sclose(mem_space);
+ H5Sclose(hyper_space);
+ H5Sclose(space);
+
+ H5Fclose(fid);
+
+}
+
int main(void){
test_group();
@@ -1067,13 +1235,12 @@ test_all();
test_loop();
test_dataset2();
-/*
test_compound_dt2();
-*/
test_loop2();
test_many();
test_str();
+test_str2();
return 0;