summaryrefslogtreecommitdiffstats
path: root/examples/h5dsm_dset_open.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2016-12-12 22:41:39 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2016-12-12 22:41:39 (GMT)
commit3889eeb5c86376fa677d48c8156584435f5cea66 (patch)
tree4e4d4b5850b8d3f6a4a409f3d64ec512f70b5ec3 /examples/h5dsm_dset_open.c
parentbbcb31845f506a167337c432c062a01936fe7118 (diff)
downloadhdf5-3889eeb5c86376fa677d48c8156584435f5cea66.zip
hdf5-3889eeb5c86376fa677d48c8156584435f5cea66.tar.gz
hdf5-3889eeb5c86376fa677d48c8156584435f5cea66.tar.bz2
Add transaction number printing for write examples, optional transaction
number arguments for read examples. Rework and fix bug in h5dsm_dset_wpartial.c. Not tested.
Diffstat (limited to 'examples/h5dsm_dset_open.c')
-rw-r--r--examples/h5dsm_dset_open.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/examples/h5dsm_dset_open.c b/examples/h5dsm_dset_open.c
index 18cfad8..8725b01 100644
--- a/examples/h5dsm_dset_open.c
+++ b/examples/h5dsm_dset_open.c
@@ -5,12 +5,13 @@ int main(int argc, char *argv[]) {
char *pool_grp = "daos_tier0";
hid_t file = -1, dset = -1, trans = -1, fapl = -1;
hsize_t dims[1] = {1};
+ uint64_t trans_num;
(void)MPI_Init(&argc, &argv);
(void)daos_init();
- if(argc != 4)
- PRINTF_ERROR("argc != 4\n");
+ if(argc < 4 || argc > 5)
+ PRINTF_ERROR("argc must be 4 or 5\n");
/* Parse UUID */
if(0 != uuid_parse(argv[1], pool_uuid))
@@ -23,9 +24,21 @@ int main(int argc, char *argv[]) {
ERROR;
/* Open file */
- if((file = H5Fopen_ff(argv[2], H5F_ACC_RDONLY, fapl, &trans)) < 0)
+ if((file = H5Fopen_ff(argv[2], H5F_ACC_RDONLY, fapl, argc == 4 ? &trans : NULL)) < 0)
ERROR;
+ /* Create transaction if specified */
+ if(argc == 5) {
+ trans_num = (uint64_t)atoi(argv[4]);
+ if((trans = H5TRcreate(file, trans_num)) < 0)
+ ERROR;
+ }
+ else
+ if(H5TRget_trans_num(trans, &trans_num) < 0)
+ ERROR;
+
+ printf("Opening dataset - transaction number = %llu\n", (long long unsigned)trans_num);
+
/* Open dataset */
if((dset = H5Dopen_ff(file, argv[3], H5P_DEFAULT, trans)) < 0)
ERROR;
@@ -35,7 +48,7 @@ int main(int argc, char *argv[]) {
ERROR;
if(H5TRclose(trans) < 0)
ERROR;
- if(H5Fclose(file) < 0)
+ if(H5Fclose_ff(file, -1) < 0)
ERROR;
if(H5Pclose(fapl) < 0)
ERROR;
@@ -50,7 +63,7 @@ error:
H5E_BEGIN_TRY {
H5Dclose_ff(dset, -1);
H5TRclose(trans);
- H5Fclose(file);
+ H5Fclose_ff(file, -1);
H5Pclose(fapl);
} H5E_END_TRY;