summaryrefslogtreecommitdiffstats
path: root/tools/lib/talign.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-10-09 04:18:18 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-10-09 04:18:18 (GMT)
commit14dcb6db33f88011c3499d439c53890ab09d1ba2 (patch)
treecc05060f7dd94342c2e06726ef6b550bf4a7d8f1 /tools/lib/talign.c
parent20720af231c875330a6074f65ee1c54e6a806fbb (diff)
downloadhdf5-14dcb6db33f88011c3499d439c53890ab09d1ba2.zip
hdf5-14dcb6db33f88011c3499d439c53890ab09d1ba2.tar.gz
hdf5-14dcb6db33f88011c3499d439c53890ab09d1ba2.tar.bz2
[svn-r12736] Description:
Add "use the latest format" support for dataspace object header encode/ decode routines and clean up format a bit for the latest format (new to 1.8.x releases) Remove storing 'perm' parameter for array datatypes in memory and the file, and add test to make certain that if any user applications are attempting to store them, we get some reports back. (Should be unlikely, since the RefMan says that the parameter is not implemented and is unsupported). Carry those changes into the tests, etc. Clean up a bunch more compiler warnings. Tested on: FreeBSD/32 4.11 (sleipnir) w/threadsafe Linux/32 2.4 (heping) w/FORTRAN & C++ Linux/64 2.4 (mir) w/enable-1.6-compat
Diffstat (limited to 'tools/lib/talign.c')
-rw-r--r--tools/lib/talign.c255
1 files changed, 128 insertions, 127 deletions
diff --git a/tools/lib/talign.c b/tools/lib/talign.c
index f8b5c87..80e83b4 100644
--- a/tools/lib/talign.c
+++ b/tools/lib/talign.c
@@ -36,154 +36,155 @@ const char *setname = "align";
int main(void)
{
- hid_t fil,spc,set;
- hid_t cs6, cmp, fix;
- hid_t cmp1, cmp2, cmp3;
- hid_t plist;
- hid_t array_dt;
+ hid_t fil,spc,set;
+ hid_t cs6, cmp, fix;
+ hid_t cmp1, cmp2, cmp3;
+ hid_t plist;
+ hid_t array_dt;
- hsize_t dim[2];
- hsize_t cdim[4];
+ hsize_t dim[2];
+ hsize_t cdim[4];
- char string5[5];
- float fok[2] = {1234., 2341.};
- float fnok[2] = {5678., 6785.};
- float *fptr;
+ char string5[5];
+ float fok[2] = {1234., 2341.};
+ float fnok[2] = {5678., 6785.};
+ float *fptr;
- char *data;
- char *mname;
+ char *data;
+ char *mname;
- int result = 0;
+ int result = 0;
- printf("%-70s", "Testing alignment in compound datatypes");
+ printf("%-70s", "Testing alignment in compound datatypes");
- strcpy(string5, "Hi!");
- HDunlink(fname);
- fil = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ strcpy(string5, "Hi!");
+ HDunlink(fname);
+ fil = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- if (fil < 0) {
- puts("*FAILED*");
- return 1;
- }
+ if (fil < 0) {
+ puts("*FAILED*");
+ return 1;
+ }
- H5E_BEGIN_TRY {
- H5Gunlink(fil, setname);
- } H5E_END_TRY;
+ H5E_BEGIN_TRY {
+ H5Gunlink(fil, setname);
+ } H5E_END_TRY;
- cs6 = H5Tcopy(H5T_C_S1);
- H5Tset_size(cs6, sizeof(string5));
- H5Tset_strpad(cs6, H5T_STR_NULLPAD);
+ cs6 = H5Tcopy(H5T_C_S1);
+ H5Tset_size(cs6, sizeof(string5));
+ H5Tset_strpad(cs6, H5T_STR_NULLPAD);
- cmp = H5Tcreate(H5T_COMPOUND, sizeof(fok) + sizeof(string5) + sizeof(fnok));
- H5Tinsert(cmp, "Awkward length", 0, cs6);
+ cmp = H5Tcreate(H5T_COMPOUND, sizeof(fok) + sizeof(string5) + sizeof(fnok));
+ H5Tinsert(cmp, "Awkward length", 0, cs6);
- cdim[0] = sizeof(fok) / sizeof(float);
- array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL);
- H5Tinsert(cmp, "Ok", sizeof(string5), array_dt);
+ cdim[0] = sizeof(fok) / sizeof(float);
+ array_dt = H5Tarray_create(H5T_NATIVE_FLOAT, 1, cdim, NULL);
+ H5Tinsert(cmp, "Ok", sizeof(string5), array_dt);
H5Tclose(array_dt);
- cdim[0] = sizeof(fnok) / sizeof(float);
- array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL);
- H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt);
+ cdim[0] = sizeof(fnok) / sizeof(float);
+ array_dt = H5Tarray_create(H5T_NATIVE_FLOAT, 1, cdim, NULL);
+ H5Tinsert(cmp, "Not Ok", sizeof(fok) + sizeof(string5), array_dt);
H5Tclose(array_dt);
- fix=h5tools_get_native_type(cmp);
+ fix=h5tools_get_native_type(cmp);
- cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok));
+ cmp1 = H5Tcreate(H5T_COMPOUND, sizeof(fok));
- cdim[0] = sizeof(fok) / sizeof(float);
- array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL);
- H5Tinsert(cmp1, "Ok", 0, array_dt);
+ cdim[0] = sizeof(fok) / sizeof(float);
+ array_dt = H5Tarray_create(H5T_NATIVE_FLOAT, 1, cdim, NULL);
+ H5Tinsert(cmp1, "Ok", 0, array_dt);
H5Tclose(array_dt);
- cmp2 = H5Tcreate(H5T_COMPOUND, sizeof(string5));
- H5Tinsert(cmp2, "Awkward length", 0, cs6);
+ cmp2 = H5Tcreate(H5T_COMPOUND, sizeof(string5));
+ H5Tinsert(cmp2, "Awkward length", 0, cs6);
- cmp3 = H5Tcreate(H5T_COMPOUND, sizeof(fnok));
+ cmp3 = H5Tcreate(H5T_COMPOUND, sizeof(fnok));
- cdim[0] = sizeof(fnok) / sizeof(float);
- array_dt=H5Tarray_create(H5T_NATIVE_FLOAT,1,cdim,NULL);
- H5Tinsert(cmp3, "Not Ok", 0, array_dt);
+ cdim[0] = sizeof(fnok) / sizeof(float);
+ array_dt = H5Tarray_create(H5T_NATIVE_FLOAT, 1, cdim, NULL);
+ H5Tinsert(cmp3, "Not Ok", 0, array_dt);
H5Tclose(array_dt);
- plist = H5Pcreate(H5P_DATASET_XFER);
- H5Pset_preserve(plist, 1);
-
- /*
- * Create a small dataset, and write data into it we write each field
- * in turn so that we are avoid alignment issues at this point
- */
- dim[0] = 1;
- spc = H5Screate_simple(1, dim, NULL);
- set = H5Dcreate(fil, setname, cmp, spc, H5P_DEFAULT);
-
- H5Dwrite(set, cmp1, spc, H5S_ALL, plist, fok);
- H5Dwrite(set, cmp2, spc, H5S_ALL, plist, string5);
- H5Dwrite(set, cmp3, spc, H5S_ALL, plist, fnok);
-
- H5Dclose(set);
-
- /* Now open the set, and read it back in */
- data = malloc(H5Tget_size(fix));
-
- if (!data) {
- perror("malloc() failed");
- abort();
- }
-
- set = H5Dopen(fil, setname);
-
- H5Dread(set, fix, spc, H5S_ALL, H5P_DEFAULT, data);
- fptr = (float *)(data + H5Tget_member_offset(fix, 1));
-
- if (fok[0] != fptr[0] || fok[1] != fptr[1]
- || fnok[0] != fptr[2] || fnok[1] != fptr[3]) {
- result = 1;
- printf("%14s (%2d) %6s = %s\n",
- mname = H5Tget_member_name(fix, 0), (int)H5Tget_member_offset(fix,0),
- string5, (char *)(data + H5Tget_member_offset(fix, 0)));
- free(mname);
- fptr = (float *)(data + H5Tget_member_offset(fix, 1));
- printf("Data comparison:\n"
- "%14s (%2d) %6f = %f\n"
- " %6f = %f\n",
- mname = H5Tget_member_name(fix, 1), (int)H5Tget_member_offset(fix,1),
- fok[0], fptr[0],
- fok[1], fptr[1]);
- free(mname);
- fptr = (float *)(data + H5Tget_member_offset(fix, 2));
- printf("%14s (%2d) %6f = %f\n"
- " %6f = %6f\n",
- mname = H5Tget_member_name(fix, 2), (int)H5Tget_member_offset(fix,2),
- fnok[0], fptr[0],
- fnok[1], fptr[1]);
- free(mname);
-
- fptr = (float *)(data + H5Tget_member_offset(fix, 1));
- printf("\n"
- "Short circuit\n"
- " %6f = %f\n"
- " %6f = %f\n"
- " %6f = %f\n"
- " %6f = %f\n",
- fok[0], fptr[0],
- fok[1], fptr[1],
- fnok[0], fptr[2],
- fnok[1], fptr[3]);
- puts("*FAILED*");
- } else {
- puts(" PASSED");
- }
-
- free(data);
- H5Sclose(spc);
- H5Tclose(cmp);
- H5Tclose(cmp1);
- H5Tclose(cmp2);
- H5Tclose(cmp3);
- H5Pclose(plist);
- H5Fclose(fil);
- unlink(fname);
- fflush(stdout);
- return result;
+ plist = H5Pcreate(H5P_DATASET_XFER);
+ H5Pset_preserve(plist, 1);
+
+ /*
+ * Create a small dataset, and write data into it we write each field
+ * in turn so that we are avoid alignment issues at this point
+ */
+ dim[0] = 1;
+ spc = H5Screate_simple(1, dim, NULL);
+ set = H5Dcreate(fil, setname, cmp, spc, H5P_DEFAULT);
+
+ H5Dwrite(set, cmp1, spc, H5S_ALL, plist, fok);
+ H5Dwrite(set, cmp2, spc, H5S_ALL, plist, string5);
+ H5Dwrite(set, cmp3, spc, H5S_ALL, plist, fnok);
+
+ H5Dclose(set);
+
+ /* Now open the set, and read it back in */
+ data = malloc(H5Tget_size(fix));
+
+ if (!data) {
+ perror("malloc() failed");
+ abort();
+ }
+
+ set = H5Dopen(fil, setname);
+
+ H5Dread(set, fix, spc, H5S_ALL, H5P_DEFAULT, data);
+ fptr = (float *)(data + H5Tget_member_offset(fix, 1));
+
+ if (fok[0] != fptr[0] || fok[1] != fptr[1]
+ || fnok[0] != fptr[2] || fnok[1] != fptr[3]) {
+ result = 1;
+ printf("%14s (%2d) %6s = %s\n",
+ mname = H5Tget_member_name(fix, 0), (int)H5Tget_member_offset(fix,0),
+ string5, (char *)(data + H5Tget_member_offset(fix, 0)));
+ free(mname);
+ fptr = (float *)(data + H5Tget_member_offset(fix, 1));
+ printf("Data comparison:\n"
+ "%14s (%2d) %6f = %f\n"
+ " %6f = %f\n",
+ mname = H5Tget_member_name(fix, 1), (int)H5Tget_member_offset(fix,1),
+ fok[0], fptr[0],
+ fok[1], fptr[1]);
+ free(mname);
+ fptr = (float *)(data + H5Tget_member_offset(fix, 2));
+ printf("%14s (%2d) %6f = %f\n"
+ " %6f = %6f\n",
+ mname = H5Tget_member_name(fix, 2), (int)H5Tget_member_offset(fix,2),
+ fnok[0], fptr[0],
+ fnok[1], fptr[1]);
+ free(mname);
+
+ fptr = (float *)(data + H5Tget_member_offset(fix, 1));
+ printf("\n"
+ "Short circuit\n"
+ " %6f = %f\n"
+ " %6f = %f\n"
+ " %6f = %f\n"
+ " %6f = %f\n",
+ fok[0], fptr[0],
+ fok[1], fptr[1],
+ fnok[0], fptr[2],
+ fnok[1], fptr[3]);
+ puts("*FAILED*");
+ } else {
+ puts(" PASSED");
+ }
+
+ free(data);
+ H5Sclose(spc);
+ H5Tclose(cmp);
+ H5Tclose(cmp1);
+ H5Tclose(cmp2);
+ H5Tclose(cmp3);
+ H5Pclose(plist);
+ H5Fclose(fil);
+ unlink(fname);
+ fflush(stdout);
+ return result;
}
+