summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2016-11-29 23:45:20 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2016-11-29 23:45:20 (GMT)
commitb866bbfe3a2f8b0c3e643a99aebf505bebc3418c (patch)
tree3d2feb0155fd32319f17b97b5cb0e19f859447ca /examples
parent2b28dc62469fb21cb0fff1082e5a6a764e2de8b7 (diff)
downloadhdf5-b866bbfe3a2f8b0c3e643a99aebf505bebc3418c.zip
hdf5-b866bbfe3a2f8b0c3e643a99aebf505bebc3418c.tar.gz
hdf5-b866bbfe3a2f8b0c3e643a99aebf505bebc3418c.tar.bz2
Fix bugs in read/write implementation. Only seems to read/write the
first element. Examples don't build correctly with make.
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am6
-rw-r--r--examples/h5dsm_dset_open.c3
-rw-r--r--examples/h5dsm_dset_read.c5
-rw-r--r--examples/h5dsm_dset_write.c18
-rw-r--r--examples/h5dsm_file_open.c10
5 files changed, 28 insertions, 14 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 2bb8bf4..623e3ae 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -42,7 +42,7 @@ EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \
h5_vds h5_vds-exc \
h5_vds-exclim h5_vds-eiger h5_vds-simpleIO h5_vds-percival \
h5_vds-percival-unlim h5_vds-percival-unlim-maxmin \
- h5dsm_file_create h5dsm_file_open h5dsm_dset_create h5dsm_dset_open
+ h5dsm_file_create h5dsm_file_open h5dsm_dset_create h5dsm_dset_open \
h5dsm_dset_write h5dsm_dset_read
TEST_SCRIPT=testh5cc.sh
TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES)
@@ -67,10 +67,10 @@ INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \
# How to build examples, using installed version of h5cc
if BUILD_PARALLEL_CONDITIONAL
$(EXTRA_PROG): $(H5CC_PP)
- $(H5CC_PP) $(H5CCFLAGS) $(CFLAGS) -o $@ $(srcdir)/$@.c;
+ $(H5CC_PP) $(H5CCFLAGS) $(CFLAGS) -luuid -o $@ $(srcdir)/$@.c;
else
$(EXTRA_PROG): $(H5CC)
- $(H5CC) $(H5CCFLAGS) $(CFLAGS) -o $@ $(srcdir)/$@.c;
+ $(H5CC) $(H5CCFLAGS) $(CFLAGS) -luuid -o $@ $(srcdir)/$@.c;
endif
# Some examples depend on files created by other examples.
diff --git a/examples/h5dsm_dset_open.c b/examples/h5dsm_dset_open.c
index c45147a..18cfad8 100644
--- a/examples/h5dsm_dset_open.c
+++ b/examples/h5dsm_dset_open.c
@@ -37,8 +37,6 @@ int main(int argc, char *argv[]) {
ERROR;
if(H5Fclose(file) < 0)
ERROR;
- if(H5Sclose(space) < 0)
- ERROR;
if(H5Pclose(fapl) < 0)
ERROR;
@@ -53,7 +51,6 @@ error:
H5Dclose_ff(dset, -1);
H5TRclose(trans);
H5Fclose(file);
- H5Sclose(space);
H5Pclose(fapl);
} H5E_END_TRY;
diff --git a/examples/h5dsm_dset_read.c b/examples/h5dsm_dset_read.c
index aeb9d71..39af503 100644
--- a/examples/h5dsm_dset_read.c
+++ b/examples/h5dsm_dset_read.c
@@ -41,7 +41,7 @@ int main(int argc, char *argv[]) {
buf[i][j] = -1;
/* Read data */
- if(H5Dread_ff(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if(H5Dread_ff(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf, trans) < 0)
ERROR;
/* Print buffer */
@@ -59,8 +59,6 @@ int main(int argc, char *argv[]) {
ERROR;
if(H5Fclose(file) < 0)
ERROR;
- if(H5Sclose(space) < 0)
- ERROR;
if(H5Pclose(fapl) < 0)
ERROR;
@@ -75,7 +73,6 @@ error:
H5Dclose_ff(dset, -1);
H5TRclose(trans);
H5Fclose(file);
- H5Sclose(space);
H5Pclose(fapl);
} H5E_END_TRY;
diff --git a/examples/h5dsm_dset_write.c b/examples/h5dsm_dset_write.c
index a49265d..9b45892 100644
--- a/examples/h5dsm_dset_write.c
+++ b/examples/h5dsm_dset_write.c
@@ -5,6 +5,7 @@ int main(int argc, char *argv[]) {
uuid_t pool_uuid;
char *pool_grp = "daos_tier0";
hid_t file = -1, dset = -1, trans = -1, fapl = -1;
+ uint64_t trans_num;
int buf[4][6];
int i, j;
@@ -35,6 +36,14 @@ int main(int argc, char *argv[]) {
if((dset = H5Dopen_ff(file, argv[3], H5P_DEFAULT, trans)) < 0)
ERROR;
+ /* Get next transaction */
+ if(H5TRget_trans_num(trans, &trans_num) < 0)
+ ERROR;
+ if(H5TRclose(trans) < 0)
+ ERROR;
+ if((trans = H5TRcreate(file, trans_num + 1)) < 0)
+ ERROR;
+
/* Fill and print buffer */
printf("Writing data. Buffer is:\n");
for(i = 0; i < 4; i++) {
@@ -46,7 +55,11 @@ int main(int argc, char *argv[]) {
}
/* Write data */
- if(H5Dwrite_ff(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ if(H5Dwrite_ff(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf, trans) < 0)
+ ERROR;
+
+ /* Commit transaction */
+ if(H5TRcommit(trans) < 0)
ERROR;
/* Close */
@@ -56,8 +69,6 @@ int main(int argc, char *argv[]) {
ERROR;
if(H5Fclose(file) < 0)
ERROR;
- if(H5Sclose(space) < 0)
- ERROR;
if(H5Pclose(fapl) < 0)
ERROR;
@@ -72,7 +83,6 @@ error:
H5Dclose_ff(dset, -1);
H5TRclose(trans);
H5Fclose(file);
- H5Sclose(space);
H5Pclose(fapl);
} H5E_END_TRY;
diff --git a/examples/h5dsm_file_open.c b/examples/h5dsm_file_open.c
index 7016699..379d39f 100644
--- a/examples/h5dsm_file_open.c
+++ b/examples/h5dsm_file_open.c
@@ -36,5 +36,15 @@ int main(int argc, char *argv[]) {
(void)MPI_Finalize();
return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)daos_fini();
+ (void)MPI_Finalize();
+ return 1;
}