diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2016-12-12 22:41:39 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2016-12-12 22:41:39 (GMT) |
commit | 3889eeb5c86376fa677d48c8156584435f5cea66 (patch) | |
tree | 4e4d4b5850b8d3f6a4a409f3d64ec512f70b5ec3 /examples/h5dsm_dset_read.c | |
parent | bbcb31845f506a167337c432c062a01936fe7118 (diff) | |
download | hdf5-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_read.c')
-rw-r--r-- | examples/h5dsm_dset_read.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/examples/h5dsm_dset_read.c b/examples/h5dsm_dset_read.c index 39af503..bd98b98 100644 --- a/examples/h5dsm_dset_read.c +++ b/examples/h5dsm_dset_read.c @@ -7,6 +7,7 @@ int main(int argc, char *argv[]) { hid_t file = -1, dset = -1, trans = -1, fapl = -1; int buf[4][6]; int i, j; + uint64_t trans_num; (void)MPI_Init(&argc, &argv); (void)daos_init(); @@ -14,8 +15,8 @@ int main(int argc, char *argv[]) { /* Seed random number generator */ srand(time(NULL)); - 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)) @@ -28,13 +29,25 @@ 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; /* Open dataset */ if((dset = H5Dopen_ff(file, argv[3], H5P_DEFAULT, trans)) < 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("Reading dataset - transaction number = %llu\n", (long long unsigned)trans_num); + /* Initialize buffer */ for(i = 0; i < 4; i++) for(j = 0; j < 6; j++) @@ -57,7 +70,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; @@ -72,7 +85,7 @@ error: H5E_BEGIN_TRY { H5Dclose_ff(dset, -1); H5TRclose(trans); - H5Fclose(file); + H5Fclose_ff(file, -1); H5Pclose(fapl); } H5E_END_TRY; |