summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2018-04-12 19:51:49 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2018-04-12 19:51:49 (GMT)
commit0185a37bb7722b42d9c141e3a29dc9fba9a12169 (patch)
tree7a11e563147710ba3dc7a83f9862f8335b83ff3a /examples
parent7dbf0958d46c322489adc7cb3e1d482b8c31ba54 (diff)
downloadhdf5-0185a37bb7722b42d9c141e3a29dc9fba9a12169.zip
hdf5-0185a37bb7722b42d9c141e3a29dc9fba9a12169.tar.gz
hdf5-0185a37bb7722b42d9c141e3a29dc9fba9a12169.tar.bz2
Add support for datasets, including I/O and partial I/O. Also support
type conversion (untested). Add more example programs. Other bug fixes/cleanup.
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am19
-rw-r--r--examples/h5rados_dset_create.c71
-rw-r--r--examples/h5rados_dset_open.c126
-rw-r--r--examples/h5rados_dset_read.c86
-rw-r--r--examples/h5rados_dset_rpartial.c142
-rw-r--r--examples/h5rados_dset_wpartial.c129
-rw-r--r--examples/h5rados_dset_write.c81
-rw-r--r--examples/h5rados_file_create.c54
-rw-r--r--examples/h5rados_file_open.c54
-rw-r--r--examples/h5rados_group_create.c63
-rw-r--r--examples/h5rados_group_open.c63
11 files changed, 887 insertions, 1 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index c8c96e8..18cafb6 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -22,7 +22,10 @@
include $(top_srcdir)/config/commence.am
if BUILD_PARALLEL_CONDITIONAL
- EXAMPLE_PROG_PARA = ph5example
+ EXAMPLE_PROG_PARA = ph5example h5rados_file_create h5rados_file_open \
+ h5rados_group_create h5rados_group_open h5rados_dset_create \
+ h5rados_dset_open h5rados_dset_write h5rados_dset_read \
+ h5rados_dset_wpartial h5rados_dset_rpartial
endif
INSTALL_SCRIPT_FILES = run-c-ex.sh
@@ -57,6 +60,10 @@ INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \
h5_vds.c h5_vds-exc.c \
h5_vds-exclim.c h5_vds-eiger.c h5_vds-simpleIO.c h5_vds-percival.c \
h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c
+ h5rados_file_create.c h5rados_file_open.c h5rados_group_create.c \
+ h5rados_group_open.c h5rados_dset_create.c \
+ h5rados_dset_open.c h5rados_dset_write.c h5rados_dset_read.c \
+ h5rados_dset_wpartial.c h5rados_dset_rpartial.c
@@ -134,6 +141,16 @@ h5_vds-simpleIO: $(srcdir)/h5_vds-simpleIO.c
h5_vds-percival: $(srcdir)/h5_vds-percival.c
h5_vds-percival-unlim: $(srcdir)/h5_vds-percival-unlim.c
h5_vds-percival-unlim-maxmin: $(srcdir)/h5_vds-percival-unlim-maxmin.c
+h5rados_file_create: $(srcdir)/h5rados_file_create.c
+h5rados_file_open: $(srcdir)/h5rados_file_open.c
+h5rados_group_create: $(srcdir)/h5rados_group_create.c
+h5rados_group_open: $(srcdir)/h5rados_group_open.c
+h5rados_dset_create: $(srcdir)/h5rados_dset_create.c
+h5rados_dset_open: $(srcdir)/h5rados_dset_open.c
+h5rados_dset_write: $(srcdir)/h5rados_dset_write.c
+h5rados_dset_read: $(srcdir)/h5rados_dset_read.c
+h5rados_dset_wpartial: $(srcdir)/h5rados_dset_wpartial.c
+h5rados_dset_rpartial: $(srcdir)/h5rados_dset_rpartial.c
if BUILD_SHARED_SZIP_CONDITIONAL
LD_LIBRARY_PATH=$(LL_PATH)
diff --git a/examples/h5rados_dset_create.c b/examples/h5rados_dset_create.c
new file mode 100644
index 0000000..3bf1fa9
--- /dev/null
+++ b/examples/h5rados_dset_create.c
@@ -0,0 +1,71 @@
+#include "h5rados_example.h"
+
+int main(int argc, char *argv[]) {
+ rados_t cluster;
+ char *pool = "mypool";
+ hid_t file = -1, dset = -1, space = -1, fapl = -1;
+ hsize_t dims[2] = {4, 6};
+
+ (void)MPI_Init(&argc, &argv);
+
+ if(argc != 3)
+ PRINTF_ERROR("argc != 3\n");
+
+ if(rados_create(&cluster, NULL) < 0)
+ ERROR;
+ if(rados_conf_read_file(cluster, "ceph.conf") < 0)
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLrados_init(cluster, pool) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_rados(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* Set up dataspace */
+ if((space = H5Screate_simple(2, dims, NULL)) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen(argv[1], H5F_ACC_RDWR, fapl)) < 0)
+ ERROR;
+
+ printf("Creating dataset\n");
+
+ /* Create dataset */
+ if((dset = H5Dcreate2(file, argv[2], H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Dclose(dset) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Sclose(space) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Fclose(file);
+ H5Sclose(space);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5rados_dset_open.c b/examples/h5rados_dset_open.c
new file mode 100644
index 0000000..19e29ed
--- /dev/null
+++ b/examples/h5rados_dset_open.c
@@ -0,0 +1,126 @@
+#include "h5rados_example.h"
+
+int main(int argc, char *argv[]) {
+ rados_t cluster;
+ char *pool = "mypool";
+ hid_t file = -1, dset = -1, fapl = -1, space = -1, type = -1, dcpl = -1, dapl = -1, def_dcpl = -1, def_dapl = -1;
+ int ndims;
+ hsize_t dims[2];
+ htri_t tri_ret;
+
+ (void)MPI_Init(&argc, &argv);
+
+ if(argc != 3)
+ PRINTF_ERROR("argc != 3\n");
+
+ if(rados_create(&cluster, NULL) < 0)
+ ERROR;
+ if(rados_conf_read_file(cluster, "ceph.conf") < 0)
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLrados_init(cluster, pool) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_rados(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0)
+ ERROR;
+
+ printf("Opening dataset\n");
+
+ /* Open dataset */
+ if((dset = H5Dopen2(file, argv[2], H5P_DEFAULT)) < 0)
+ ERROR;
+
+ /* Check dataset dataspace */
+ if((space = H5Dget_space(dset)) < 0)
+ ERROR;
+ if((ndims = H5Sget_simple_extent_ndims(space)) < 0)
+ ERROR;
+ if(ndims != 2)
+ PRINTF_ERROR("ndims == %d, expected 2\n", ndims);
+ if(H5Sget_simple_extent_dims(space, dims, NULL) < 0)
+ ERROR;
+ if(dims[0] != 4)
+ PRINTF_ERROR("dims[0] == %d, expected 4\n", (int)dims[0]);
+ if(dims[1] != 6)
+ PRINTF_ERROR("dims[1] == %d, expected 6\n", (int)dims[1]);
+
+ /* Check dataset datatype */
+ if((type = H5Dget_type(dset)) < 0)
+ ERROR;
+ if((tri_ret = H5Tequal(type, H5T_NATIVE_INT)) < 0)
+ ERROR;
+ if(!tri_ret)
+ PRINTF_ERROR("datatype does not equal H5T_NATIVE_INT\n");
+
+ /* Check DCPL */
+ if((dcpl = H5Dget_create_plist(dset)) < 0)
+ ERROR;
+ if((def_dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ ERROR;
+ if((tri_ret = H5Pequal(dcpl, def_dcpl)) < 0)
+ ERROR;
+ if(!tri_ret)
+ PRINTF_ERROR("DCPL does not equal default\n");
+
+ /* Check DAPL */
+ if((dapl = H5Dget_access_plist(dset)) < 0)
+ ERROR;
+ if((def_dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0)
+ ERROR;
+ if((tri_ret = H5Pequal(dapl, def_dapl)) < 0)
+ ERROR;
+ if(!tri_ret)
+ PRINTF_ERROR("DAPL does not equal default\n");
+
+ /* Close */
+ if(H5Dclose(dset) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+ if(H5Sclose(space) < 0)
+ ERROR;
+ if(H5Tclose(type) < 0)
+ ERROR;
+ if(H5Pclose(dcpl) < 0)
+ ERROR;
+ if(H5Pclose(dapl) < 0)
+ ERROR;
+ if(H5Pclose(def_dcpl) < 0)
+ ERROR;
+ if(H5Pclose(def_dapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Fclose(file);
+ H5Pclose(fapl);
+ H5Sclose(space);
+ H5Tclose(type);
+ H5Pclose(dcpl);
+ H5Pclose(dapl);
+ H5Pclose(def_dcpl);
+ H5Pclose(def_dapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5rados_dset_read.c b/examples/h5rados_dset_read.c
new file mode 100644
index 0000000..fc7292c
--- /dev/null
+++ b/examples/h5rados_dset_read.c
@@ -0,0 +1,86 @@
+#include "h5rados_example.h"
+#include <time.h>
+
+int main(int argc, char *argv[]) {
+ rados_t cluster;
+ char *pool = "mypool";
+ hid_t file = -1, dset = -1, fapl = -1;
+ int buf[4][6];
+ int i, j;
+
+ (void)MPI_Init(&argc, &argv);
+
+ /* Seed random number generator */
+ srand(time(NULL));
+
+ if(argc != 3)
+ PRINTF_ERROR("argc != 3\n");
+
+ if(rados_create(&cluster, NULL) < 0)
+ ERROR;
+ if(rados_conf_read_file(cluster, "ceph.conf") < 0)
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLrados_init(cluster, pool) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_rados(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0)
+ ERROR;
+
+ /* Open dataset */
+ if((dset = H5Dopen2(file, argv[2], H5P_DEFAULT)) < 0)
+ ERROR;
+
+ printf("Reading dataset\n");
+
+ /* Initialize buffer */
+ for(i = 0; i < 4; i++)
+ for(j = 0; j < 6; j++)
+ buf[i][j] = -1;
+
+ /* Read data */
+ if(H5Dread(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ ERROR;
+
+ /* Print buffer */
+ printf("Successfully read data. Buffer is:\n");
+ for(i = 0; i < 4; i++) {
+ for(j = 0; j < 6; j++)
+ printf("%d ", buf[i][j]);
+ printf("\n");
+ }
+
+ /* Close */
+ if(H5Dclose(dset) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5rados_dset_rpartial.c b/examples/h5rados_dset_rpartial.c
new file mode 100644
index 0000000..622b961
--- /dev/null
+++ b/examples/h5rados_dset_rpartial.c
@@ -0,0 +1,142 @@
+#include "h5rados_example.h"
+#include <time.h>
+
+int main(int argc, char *argv[]) {
+ rados_t cluster;
+ char *pool = "mypool";
+ hid_t file = -1, dset = -1, file_space = -1, mem_space = -1, fapl = -1;
+ hsize_t dims[2] = {4, 6};
+ hsize_t start[2], count[2];
+ int buf[4][6];
+ int rank, mpi_size;
+ char *file_sel_str[2] = {"XXX...", "...XXX"};
+ int i, j;
+
+ (void)MPI_Init(&argc, &argv);
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
+
+ if(mpi_size > 2)
+ PRINTF_ERROR("mpi_size > 2\n");
+
+ /* Seed random number generator */
+ srand(time(NULL));
+
+ if(argc != 3)
+ PRINTF_ERROR("argc != 3\n");
+
+ if(rados_create(&cluster, NULL) < 0)
+ ERROR;
+ if(rados_conf_read_file(cluster, "ceph.conf") < 0)
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLrados_init(cluster, pool) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_rados(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen(argv[1], H5F_ACC_RDWR, fapl)) < 0)
+ ERROR;
+
+ /* Open dataset */
+ if((dset = H5Dopen2(file, argv[2], H5P_DEFAULT)) < 0)
+ ERROR;
+
+ if(rank == 1)
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ printf("---------------Rank %d---------------\n", rank);
+ printf("Selecting elements denoted with X\n");
+ printf("Memory File\n");
+ printf("...... %s\n", file_sel_str[rank]);
+ for(i = 1; i < 4; i++)
+ printf(".XXXX. %s\n", file_sel_str[rank]);
+
+ if(rank == 0)
+ MPI_Barrier(MPI_COMM_WORLD);
+ else
+ printf("Reading dataset\n");
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* Set up dataspaces */
+ if((file_space = H5Screate_simple(2, dims, NULL)) < 0)
+ ERROR;
+ if((mem_space = H5Screate_simple(2, dims, NULL)) < 0)
+ ERROR;
+ start[0] = 0;
+ start[1] = 3 * rank;
+ count[0] = 4;
+ count[1] = 3;
+ if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
+ ERROR;
+ start[0] = 1;
+ start[1] = 1;
+ count[0] = 3;
+ count[1] = 4;
+ if(H5Sselect_hyperslab(mem_space, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
+ ERROR;
+
+ /* Initialize buffer */
+ for(i = 0; i < 4; i++)
+ for(j = 0; j < 6; j++)
+ buf[i][j] = -1;
+
+ /* Read data */
+ if(H5Dread(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf) < 0)
+ ERROR;
+
+ if(rank == 1)
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* Fill and print buffer */
+ printf("---------------Rank %d---------------\n", rank);
+ printf("Successfully read data. Buffer is:\n");
+ for(i = 0; i < 4; i++) {
+ for(j = 0; j < 6; j++)
+ printf("%d ", buf[i][j]);
+ printf("\n");
+ }
+
+ if(rank == 0)
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /* Close */
+ if(H5Dclose(dset) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Sclose(file_space) < 0)
+ ERROR;
+ if(H5Sclose(mem_space) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Fclose(file);
+ H5Sclose(file_space);
+ H5Sclose(mem_space);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5rados_dset_wpartial.c b/examples/h5rados_dset_wpartial.c
new file mode 100644
index 0000000..bb53982
--- /dev/null
+++ b/examples/h5rados_dset_wpartial.c
@@ -0,0 +1,129 @@
+#include "h5rados_example.h"
+#include <time.h>
+
+int main(int argc, char *argv[]) {
+ rados_t cluster;
+ char *pool = "mypool";
+ hid_t file = -1, dset = -1, file_space = -1, mem_space = -1, fapl = -1;
+ hsize_t dims[2] = {4, 6};
+ hsize_t start[2], count[2];
+ int buf[4][6];
+ int rank, mpi_size;
+ char *file_sel_str[2] = {"XXX...", "...XXX"};
+ int i, j;
+
+ (void)MPI_Init(&argc, &argv);
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
+
+ if(mpi_size != 2)
+ PRINTF_ERROR("mpi_size != 2\n");
+
+ /* Seed random number generator */
+ srand(time(NULL));
+
+ if(argc != 3)
+ PRINTF_ERROR("argc != 3\n");
+
+ if(rados_create(&cluster, NULL) < 0)
+ ERROR;
+ if(rados_conf_read_file(cluster, "ceph.conf") < 0)
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLrados_init(cluster, pool) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_rados(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen(argv[1], H5F_ACC_RDWR, fapl)) < 0)
+ ERROR;
+
+ /* Open dataset */
+ if((dset = H5Dopen2(file, argv[2], H5P_DEFAULT)) < 0)
+ ERROR;
+
+ if(rank == 1)
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ printf("---------------Rank %d---------------\n", rank);
+ printf("Selecting elements denoted with X\n");
+ printf("Memory File\n");
+ printf("...... %s\n", file_sel_str[rank]);
+ for(i = 1; i < 4; i++)
+ printf(".XXXX. %s\n", file_sel_str[rank]);
+
+ /* Fill and print buffer */
+ printf("Writing data. Buffer is:\n");
+ for(i = 0; i < 4; i++) {
+ for(j = 0; j < 6; j++) {
+ buf[i][j] = rand() % 10;
+ printf("%d ", buf[i][j]);
+ }
+ printf("\n");
+ }
+
+ if(rank == 0)
+ MPI_Barrier(MPI_COMM_WORLD);
+
+
+ /* Set up dataspaces */
+ if((file_space = H5Screate_simple(2, dims, NULL)) < 0)
+ ERROR;
+ if((mem_space = H5Screate_simple(2, dims, NULL)) < 0)
+ ERROR;
+ start[0] = 0;
+ start[1] = 3 * rank;
+ count[0] = 4;
+ count[1] = 3;
+ if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
+ ERROR;
+ start[0] = 1;
+ start[1] = 1;
+ count[0] = 3;
+ count[1] = 4;
+ if(H5Sselect_hyperslab(mem_space, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
+ ERROR;
+
+ /* Write data */
+ if(H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Dclose(dset) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Sclose(file_space) < 0)
+ ERROR;
+ if(H5Sclose(mem_space) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Fclose(file);
+ H5Sclose(file_space);
+ H5Sclose(mem_space);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5rados_dset_write.c b/examples/h5rados_dset_write.c
new file mode 100644
index 0000000..dad96fa
--- /dev/null
+++ b/examples/h5rados_dset_write.c
@@ -0,0 +1,81 @@
+#include "h5rados_example.h"
+#include <time.h>
+
+int main(int argc, char *argv[]) {
+ rados_t cluster;
+ char *pool = "mypool";
+ hid_t file = -1, dset = -1, fapl = -1;
+ int buf[4][6];
+ int i, j;
+
+ (void)MPI_Init(&argc, &argv);
+
+ /* Seed random number generator */
+ srand(time(NULL));
+
+ if(argc != 3)
+ PRINTF_ERROR("argc != 3\n");
+
+ if(rados_create(&cluster, NULL) < 0)
+ ERROR;
+ if(rados_conf_read_file(cluster, "ceph.conf") < 0)
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLrados_init(cluster, pool) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_rados(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen(argv[1], H5F_ACC_RDWR, fapl)) < 0)
+ ERROR;
+
+ /* Open dataset */
+ if((dset = H5Dopen2(file, argv[2], H5P_DEFAULT)) < 0)
+ ERROR;
+
+ /* Fill and print buffer */
+ printf("Writing data. Buffer is:\n");
+ for(i = 0; i < 4; i++) {
+ for(j = 0; j < 6; j++) {
+ buf[i][j] = rand() % 10;
+ printf("%d ", buf[i][j]);
+ }
+ printf("\n");
+ }
+
+ /* Write data */
+ if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Dclose(dset) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset);
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5rados_file_create.c b/examples/h5rados_file_create.c
new file mode 100644
index 0000000..493be18
--- /dev/null
+++ b/examples/h5rados_file_create.c
@@ -0,0 +1,54 @@
+#include "h5rados_example.h"
+
+int main(int argc, char *argv[]) {
+ rados_t cluster;
+ char *pool = "mypool";
+ hid_t file = -1, fapl = -1;
+
+ (void)MPI_Init(&argc, &argv);
+
+ if(argc != 2)
+ PRINTF_ERROR("argc != 2\n");
+
+ if(rados_create(&cluster, NULL) < 0)
+ ERROR;
+ if(rados_conf_read_file(cluster, "ceph.conf") < 0)
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLrados_init(cluster, pool) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_rados(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* Create file */
+ if((file = H5Fcreate(argv[1], H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5rados_file_open.c b/examples/h5rados_file_open.c
new file mode 100644
index 0000000..176d26e
--- /dev/null
+++ b/examples/h5rados_file_open.c
@@ -0,0 +1,54 @@
+#include "h5rados_example.h"
+
+int main(int argc, char *argv[]) {
+ rados_t cluster;
+ char *pool = "mypool";
+ hid_t file = -1, fapl = -1;
+
+ (void)MPI_Init(&argc, &argv);
+
+ if(argc != 2)
+ PRINTF_ERROR("argc != 2\n");
+
+ if(rados_create(&cluster, NULL) < 0)
+ ERROR;
+ if(rados_conf_read_file(cluster, "ceph.conf") < 0)
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLrados_init(cluster, pool) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_rados(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* Create file */
+ if((file = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5rados_group_create.c b/examples/h5rados_group_create.c
new file mode 100644
index 0000000..fcfbbc0
--- /dev/null
+++ b/examples/h5rados_group_create.c
@@ -0,0 +1,63 @@
+#include "h5rados_example.h"
+
+int main(int argc, char *argv[]) {
+ rados_t cluster;
+ char *pool = "mypool";
+ hid_t file = -1, fapl = -1, grp = -1;
+
+ (void)MPI_Init(&argc, &argv);
+
+ if(argc != 3)
+ PRINTF_ERROR("argc != 3\n");
+
+ if(rados_create(&cluster, NULL) < 0)
+ ERROR;
+ if(rados_conf_read_file(cluster, "ceph.conf") < 0)
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLrados_init(cluster, pool) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_rados(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* OPEN file */
+ if((file = H5Fopen(argv[1], H5F_ACC_RDWR, fapl)) < 0)
+ ERROR;
+
+ printf("Creating group\n");
+
+ /* Create group */
+ if((grp = H5Gcreate2(file, argv[2], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Gclose(grp) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(grp);
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+
diff --git a/examples/h5rados_group_open.c b/examples/h5rados_group_open.c
new file mode 100644
index 0000000..3339480
--- /dev/null
+++ b/examples/h5rados_group_open.c
@@ -0,0 +1,63 @@
+#include "h5rados_example.h"
+
+int main(int argc, char *argv[]) {
+ rados_t cluster;
+ char *pool = "mypool";
+ hid_t file = -1, fapl = -1, grp = -1;
+
+ (void)MPI_Init(&argc, &argv);
+
+ if(argc != 3)
+ PRINTF_ERROR("argc != 3\n");
+
+ if(rados_create(&cluster, NULL) < 0)
+ ERROR;
+ if(rados_conf_read_file(cluster, "ceph.conf") < 0)
+ ERROR;
+
+ /* Initialize VOL */
+ if(H5VLrados_init(cluster, pool) < 0)
+ ERROR;
+
+ /* Set up FAPL */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ ERROR;
+ if(H5Pset_fapl_rados(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ ERROR;
+ if(H5Pset_all_coll_metadata_ops(fapl, true) < 0)
+ ERROR;
+
+ /* Open file */
+ if((file = H5Fopen(argv[1], H5F_ACC_RDONLY, fapl)) < 0)
+ ERROR;
+
+ printf("Opening group\n");
+
+ /* Open group */
+ if((grp = H5Gopen2(file, argv[2], H5P_DEFAULT)) < 0)
+ ERROR;
+
+ /* Close */
+ if(H5Gclose(grp) < 0)
+ ERROR;
+ if(H5Fclose(file) < 0)
+ ERROR;
+ if(H5Pclose(fapl) < 0)
+ ERROR;
+
+ printf("Success\n");
+
+ (void)MPI_Finalize();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Gclose(grp);
+ H5Fclose(file);
+ H5Pclose(fapl);
+ } H5E_END_TRY;
+
+ (void)MPI_Finalize();
+ return 1;
+}
+