summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-01-28 18:52:53 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-01-28 18:52:53 (GMT)
commit3e601905e38451e5aa003d472fdfb45338d50fe9 (patch)
treef27930c99def09c98fcc73058e5e2fce41536b26
parentc0cfc4421ad7c95c46c2a654f8c06bff8db3588f (diff)
downloadhdf5-3e601905e38451e5aa003d472fdfb45338d50fe9.zip
hdf5-3e601905e38451e5aa003d472fdfb45338d50fe9.tar.gz
hdf5-3e601905e38451e5aa003d472fdfb45338d50fe9.tar.bz2
[svn-r186] Changes since 19980128
---------------------- ./config/conclude.in The maintainer-clean target removes Emacs backup files, mirroring backup and contrib files, core files, and profile output files in addition to what it used to remove. ./src/H5D.c Fixed a buffer allocation bug in the output pipeline. ./src/H5Gnode.c Fixed a comparison against size_t ./test/Makefile.in Added the other temporary h5 files to the `MOSTLYCLEAN' var. ./test/cmpd_dset.c Added four tests for partial I/O. Don't you just love it when something works on the first try!
-rw-r--r--config/conclude.in1
-rw-r--r--src/H5D.c2
-rw-r--r--src/H5Gnode.c2
-rw-r--r--test/Makefile.in3
-rw-r--r--test/cmpd_dset.c201
5 files changed, 191 insertions, 18 deletions
diff --git a/config/conclude.in b/config/conclude.in
index 3daa001..01002e4 100644
--- a/config/conclude.in
+++ b/config/conclude.in
@@ -77,6 +77,7 @@ distclean: clean
# the makefile, including those generated from autoheader and autoconf.
#
maintainer-clean: distclean
+ $(RM) *~ core core.* *.core *.bak *.contrib gmon.out
# Implicit rules
.c.a:
diff --git a/src/H5D.c b/src/H5D.c
index 460a903..8b88622 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1072,7 +1072,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
/*
* Compute the size of the request and allocate scratch buffers.
*/
- nelmts = H5P_get_npoints(dataset->space);
+ nelmts = H5P_get_npoints(mem_space);
#ifndef LATER
/*
* Note: This prototype version allocates a buffer large enough to
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index 5eb24d7..5e6c862 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -758,7 +758,7 @@ H5G_node_insert(H5F_t *f, const haddr_t *addr,
offset = H5H_insert(f, &(bt_udata->heap_addr), HDstrlen(bt_udata->name)+1,
bt_udata->name);
bt_udata->ent.name_off = offset;
- if (offset <= 0) {
+ if (0==offset || (size_t)(-1)==offset) {
HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR,
"unable to insert symbol name into heap");
}
diff --git a/test/Makefile.in b/test/Makefile.in
index f85878e..a2259cd 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -15,7 +15,8 @@ PROGS=testhdf5 hyperslab istore dtypes dsets cmpd_dset
TESTS=$(PROGS)
# Temporary files
-MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 istore.h5
+MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 istore.h5 tfile1.h5 tfile2.h5 \
+ tfile3.h5 th5p1.h5 theap.h5 tohdr.h5 tstab1.h5 tstab2.h5
# Source and object files for programs... The PROG_SRC list contains all the
# source files and is used for things like dependencies, archiving, etc. The
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c
index 1836a79..92b930f 100644
--- a/test/cmpd_dset.c
+++ b/test/cmpd_dset.c
@@ -6,8 +6,10 @@
* Friday, January 23, 1998
*/
#include <assert.h>
-#include <stdio.h>
#include <hdf5.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
/* The first dataset */
typedef struct s1_t {
@@ -50,8 +52,13 @@ typedef struct s5_t {
} s5_t;
-#define NX 100
-#define NY 2000
+#if 1
+# define NX 100
+# define NY 2000
+#else
+# define NX 12
+# define NY 9
+#endif
/*-------------------------------------------------------------------------
@@ -105,8 +112,15 @@ main (void)
hid_t s8_f_sid; /*file data space */
hid_t s8_m_sid; /*memory data space */
+ /* Ninth dataset */
+
+ /* Tenth dataset */
+
+ /* Eleventh dataset */
+ s5_t *s11 = NULL;
+
/* Other variables */
- int i;
+ int i, j, ndims;
hid_t file, dataset, space;
herr_t status;
static size_t dim[] = {NX, NY};
@@ -130,7 +144,7 @@ main (void)
* STEP 1: Save the original dataset natively.
*/
printf ("\
-STEP 1: Initialize dataset `s1' and store it on disk in native order.\n");
+STEP 1: Initialize dataset `s1' and store it on disk in native order.\n");
fflush (stdout);
/* Initialize the dataset */
@@ -166,8 +180,8 @@ STEP 1: Initialize dataset `s1' and store it on disk in native order.\n");
* in fact, we could have used s1_tid.
*/
printf ("\
-STEP 2: Read the dataset from disk into a new memory buffer which has the\n\
- same data type and space. This will be the typical case.\n");
+STEP 2: Read the dataset from disk into a new memory buffer which has the\n\
+ same data type and space. This will be the typical case.\n");
fflush (stdout);
@@ -200,7 +214,7 @@ STEP 2: Read the dataset from disk into a new memory buffer which has the\n\
* data type is a struct whose members are in the opposite order.
*/
printf ("\
-STEP 3: Read the dataset again with members in a different order.\n");
+STEP 3: Read the dataset again with members in a different order.\n");
fflush (stdout);
/* Create a data type for s3 */
@@ -231,7 +245,7 @@ STEP 3: Read the dataset again with members in a different order.\n");
* stored on disk we'll read <b,d>.
*/
printf ("\
-STEP 4: Read a subset of the members.\n");
+STEP 4: Read a subset of the members.\n");
fflush (stdout);
/* Create a datatype for s4 */
@@ -256,7 +270,7 @@ STEP 4: Read a subset of the members.\n");
* which have already been initialized.
*/
printf ("\
-STEP 5: Read members into a superset which is partially initialized.\n");
+STEP 5: Read members into a superset which is partially initialized.\n");
fflush (stdout);
/* Initialize some members */
@@ -304,8 +318,8 @@ STEP 5: Read members into a superset which is partially initialized.\n");
* buffers.
*/
printf ("\
-STEP 6: Update fields `b' and `d' on the file, leaving the other fields\n\
- unchanged.\n");
+STEP 6: Update fields `b' and `d' on the file, leaving the other fields\n\
+ unchanged.\n");
fflush (stdout);
/* Initialize `s4' with new values */
@@ -338,7 +352,7 @@ STEP 6: Update fields `b' and `d' on the file, leaving the other fields\n\
* library.
*/
printf ("\
-STEP 7: Reading original dataset with explicit data space.\n");
+STEP 7: Reading original dataset with explicit data space.\n");
fflush (stdout);
/* Create the data space */
@@ -365,7 +379,7 @@ STEP 7: Reading original dataset with explicit data space.\n");
* The hyperslab is the middle third of the array.
*/
printf ("\
-STEP 8: Read middle third hyperslab into memory array.\n");
+STEP 8: Read middle third hyperslab into memory array.\n");
fflush (stdout);
/* Create the file data space */
@@ -374,7 +388,7 @@ STEP 8: Read middle third hyperslab into memory array.\n");
f_offset[0] = NX/3;
f_offset[1] = NY/3;
h_size[0] = 2*NX/3 - f_offset[0];
- h_size[1] = 2*NY/3 - f_offset[0];
+ h_size[1] = 2*NY/3 - f_offset[1];
h_sample[0] = 1;
h_sample[1] = 1;
status = H5Pset_hyperslab (s8_f_sid, f_offset, h_size, h_sample);
@@ -386,10 +400,167 @@ STEP 8: Read middle third hyperslab into memory array.\n");
/* Read the dataset */
s8 = calloc (h_size[0]*h_size[1], sizeof(s1_t));
+ assert (s8);
status = H5Dread (dataset, s1_tid, s8_m_sid, s8_f_sid, H5C_DEFAULT, s8);
assert (status>=0);
+
+ /* Compare */
+ for (i=0; i<h_size[0]; i++) {
+ for (j=0; j<h_size[1]; j++) {
+ s1_t *ps1 = s1 + (f_offset[0]+i)*NY + f_offset[1] + j;
+ s1_t *ps8 = s8 + i*h_size[1] + j;
+
+ assert (ps8->a == ps1->a);
+ assert (ps8->b == ps1->b);
+ assert (ps8->c == ps1->c);
+ assert (ps8->d == ps1->d);
+ assert (ps8->e == ps1->e);
+ }
+ }
+
+ free (s8);
+ s8 = NULL;
+
+
+ /*
+ *######################################################################
+ * STEP 9. Read a hyperslab of the file into a hyperslab of memory. The
+ * part of memory not read is already initialized and must not change.
+ */
+ printf ("\
+STEP 9: Read middle third of hyperslab into middle third of memory array.\n");
+ fflush (stdout);
+
+ /* Initialize with some bit pattern */
+ memset (s2, 0xFF, NX*NY*sizeof(s2_t));
+
+ /* Read the hyperslab */
+ status = H5Dread (dataset, s2_tid, s8_f_sid, s8_f_sid, H5C_DEFAULT, s2);
+ assert (status>=0);
+
+ /* Compare */
+ for (i=0; i<NX; i++) {
+ for (j=0; j<NY; j++) {
+ s1_t *ps1 = s1 + i*NY + j;
+ s2_t *ps2 = s2 + i*NY + j;
+ if (i>=f_offset[0] && i<f_offset[0]+h_size[0] &&
+ j>=f_offset[1] && j<f_offset[1]+h_size[1]) {
+ assert (ps2->a == ps1->a);
+ assert (ps2->b == ps1->b);
+ assert (ps2->c == ps1->c);
+ assert (ps2->d == ps1->d);
+ assert (ps2->e == ps1->e);
+ } else {
+ assert (ps2->a == -1);
+ assert (ps2->b == -1);
+ assert (ps2->c == -1);
+ assert (ps2->d == -1);
+ assert (ps2->e == -1);
+ }
+ }
+ }
+ /*
+ *######################################################################
+ * STEP 10. Same as step 9 except the memory array contains some members
+ * which are already initialized, like step 5.
+ */
+ printf ("\
+STEP 10: Read middle third of hyperslab into middle third of memory array\n\
+ where some of the struct members are already initialized.\n");
+ fflush (stdout);
+ /* Initialize with some bit pattern */
+ memset (s5, 0xFF, NX*NY*sizeof(s5_t));
+
+ /* Read the hyperslab */
+ status = H5Dread (dataset, s5_tid, s8_f_sid, s8_f_sid, H5C_DEFAULT, s5);
+ assert (status>=0);
+
+ /* Compare */
+ for (i=0; i<NX; i++) {
+ for (j=0; j<NY; j++) {
+ s1_t *ps1 = s1 + i*NY + j;
+ s5_t *ps5 = s5 + i*NY + j;
+ if (i>=f_offset[0] && i<f_offset[0]+h_size[0] &&
+ j>=f_offset[1] && j<f_offset[1]+h_size[1]) {
+ assert (ps5->pre == -1);
+ assert (ps5->a == ps1->a);
+ assert (ps5->b == ps1->b);
+ assert (ps5->mid1 == -1);
+ assert (ps5->c == ps1->c);
+ assert (ps5->mid2 == -1);
+ assert (ps5->d == ps1->d);
+ assert (ps5->e == ps1->e);
+ assert (ps5->post == -1);
+ } else {
+ assert (ps5->pre == -1);
+ assert (ps5->a == -1);
+ assert (ps5->b == -1);
+ assert (ps5->mid1 == -1);
+ assert (ps5->c == -1);
+ assert (ps5->mid2 == -1);
+ assert (ps5->d == -1);
+ assert (ps5->e == -1);
+ assert (ps5->post == -1);
+ }
+ }
+ }
+
+ /*
+ *######################################################################
+ * Step 11: Write an array into the middle third of the dataset
+ * initializeing only members `b' and `d' to -1.
+ */
+ printf ("\
+STEP 11: Write an array back to the middle third of the dataset to\n\
+ initialize the `b' and `d' members to -1.\n");
+ fflush (stdout);
+
+ /* Create the memory array and initialize all fields to zero */
+ ndims = H5Pget_hyperslab (s8_f_sid, f_offset, h_size, h_sample);
+ assert (ndims==2);
+ s11 = malloc (h_size[0]*h_size[1]*sizeof(s4_t));
+ assert (s11);
+ memset (s11, 0xff, h_size[0]*h_size[1]*sizeof(s4_t));
+
+ /* Write to disk */
+ status = H5Dwrite (dataset, s4_tid, s8_m_sid, s8_f_sid, H5C_DEFAULT, s11);
+ assert (status>=0);
+
+ /* Read the whole thing */
+ status = H5Dread (dataset, s1_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s1);
+ assert (status>=0);
+
+ /* Compare */
+ for (i=0; i<NX; i++) {
+ for (j=0; j<NY; j++) {
+ s1_t *ps1 = s1 + i*NY + j;
+
+ assert (ps1->a == 5*(i*NY+j)+0);
+ assert (ps1->c == 5*(i*NY+j)+2);
+ assert (ps1->e == 5*(i*NY+j)+4);
+ if (i>=f_offset[0] && i<f_offset[0]+h_size[0] &&
+ j>=f_offset[1] && j<f_offset[1]+h_size[1]) {
+ assert (ps1->b == -1);
+ assert (ps1->d == -1);
+ } else {
+ assert (ps1->b == 5*(i*NY+j)+1);
+ assert (ps1->d == 5*(i*NY+j)+3);
+ }
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+
/*
* Release resources.
*/