diff --git a/examples/H5Part/read_canonicalview.c b/examples/H5Part/read_canonicalview.c index a2c0189..0093aee 100644 --- a/examples/H5Part/read_canonicalview.c +++ b/examples/H5Part/read_canonicalview.c @@ -9,19 +9,26 @@ #include "H5hut.h" -#define FNAME "example_setview.h5" -#define VERBOSITY H5_VERBOSE_DEFAULT +#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT + +#define FNAME "example_setview.h5" + int main ( int argc, char* argv[] ){ + h5_int64_t verbosity = DEFAULT_VERBOSITY; + // initialize MPI & H5hut - int mpi_rank = 0; - int mpi_size = 1; + int comm_rank = 0; + int comm_size = 1; MPI_Init (&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; - MPI_Comm_rank (comm, &mpi_rank); - MPI_Comm_size (comm, &mpi_size); + MPI_Comm_rank (comm, &comm_rank); + MPI_Comm_size (comm, &comm_size); + + H5AbortOnError (); + H5SetVerbosityLevel (verbosity); // open file and go to step#0 h5_file_t file = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT); diff --git a/examples/H5Part/read_setview.c b/examples/H5Part/read_setview.c index 4974d86..013a93b 100644 --- a/examples/H5Part/read_setview.c +++ b/examples/H5Part/read_setview.c @@ -8,21 +8,27 @@ */ #include "H5hut.h" -#include "examples.h" -#define FNAME "example_setview.h5" +#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT + +#define FNAME "example_setview.h5" int main ( int argc, char* argv[] ){ + h5_int64_t verbosity = DEFAULT_VERBOSITY; + // initialize MPI & H5hut - int mpi_rank = 0; - int mpi_size = 1; + int comm_rank = 0; + int comm_size = 1; MPI_Init (&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; - MPI_Comm_rank (comm, &mpi_rank); - MPI_Comm_size (comm, &mpi_size); + MPI_Comm_rank (comm, &comm_rank); + MPI_Comm_size (comm, &comm_size); + + H5AbortOnError (); + H5SetVerbosityLevel (verbosity); // open file and go to step#0 h5_file_t file = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT); @@ -31,17 +37,17 @@ main ( // compute a "canonical" view: all cores get almost the same number of // particles h5_int64_t total_particles = H5PartGetNumParticles (file); - h5_int64_t nparticles = total_particles / mpi_size; - h5_int64_t remainder = total_particles % mpi_size; - h5_int64_t start = mpi_rank * nparticles; + h5_int64_t nparticles = total_particles / comm_size; + h5_int64_t remainder = total_particles % comm_size; + h5_int64_t start = comm_rank * nparticles; // adjust number of local particles - if (mpi_rank < remainder) + if (comm_rank < remainder) nparticles++; // adjust start - if (mpi_rank < remainder) - start += mpi_rank; + if (comm_rank < remainder) + start += comm_rank; else start += remainder; @@ -49,14 +55,14 @@ main ( // this forces the selection of zero particles! h5_int64_t end = start + nparticles - 1; - printf ("[proc %d]: set view to [%lld..%lld]\n", mpi_rank, start, end); + printf ("[proc %d]: set view to [%lld..%lld]\n", comm_rank, start, end); H5PartSetView (file, start, end); h5_int32_t* data = calloc (nparticles, sizeof (*data)); H5PartReadDataInt32 (file, "data", data); for (int i = 0; i < nparticles; i++) { printf ("[proc %d]: global index = %lld; local index = %d, value = %d\n", - mpi_rank, start+i, i, data[i]); + comm_rank, start+i, i, data[i]); } H5CloseFile (file); return MPI_Finalize (); diff --git a/examples/H5Part/read_strided.c b/examples/H5Part/read_strided.c index 18e2859..e7162ad 100644 --- a/examples/H5Part/read_strided.c +++ b/examples/H5Part/read_strided.c @@ -8,20 +8,25 @@ */ #include "H5hut.h" -#include "examples.h" -#define FNAME "example_particles.h5" +#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT + +#define FNAME "example_particles.h5" int main ( int argc, char* argv[] ){ - H5AbortOnError (); - H5SetVerbosityLevel (VERBOSITY); + h5_int64_t verbosity = DEFAULT_VERBOSITY; - int myproc; + // initialize MPI & H5hut MPI_Init (&argc, &argv); - MPI_Comm_rank (MPI_COMM_WORLD, &myproc); + MPI_Comm comm = MPI_COMM_WORLD; + int rank = 0; + MPI_Comm_rank (comm, &rank); + + H5AbortOnError (); + H5SetVerbosityLevel (verbosity); h5_file_t file = H5OpenFile (FNAME, H5_O_RDONLY, H5_PROP_DEFAULT); diff --git a/examples/H5Part/use_core_vfd.c b/examples/H5Part/use_core_vfd.c index 44eac11..f36b5ef 100644 --- a/examples/H5Part/use_core_vfd.c +++ b/examples/H5Part/use_core_vfd.c @@ -8,29 +8,32 @@ */ #include "H5hut.h" -#include "examples.h" -#include -#include +#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT -#define FNAME "example_core_vfd" -#define DATASIZE 32 +#define FNAME "example_core_vfd" +#define DATASIZE 32 int main ( int argc, char* argv[] ){ + h5_int64_t verbosity = DEFAULT_VERBOSITY; + // initialize MPI & H5hut - int mpi_rank = 0; - int mpi_size = 1; + int comm_rank = 0; + int comm_size = 1; MPI_Init (&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; - MPI_Comm_rank (comm, &mpi_rank); - MPI_Comm_size (comm, &mpi_size); + MPI_Comm_rank (comm, &comm_rank); + MPI_Comm_size (comm, &comm_size); + + H5AbortOnError (); + H5SetVerbosityLevel (verbosity); // open file and go to step#0 char fname[64]; - sprintf (fname, "%s.%d.h5", FNAME, mpi_rank); + sprintf (fname, "%s.%d.h5", FNAME, comm_rank); h5_prop_t prop = H5CreateFileProp (); H5SetPropFileCoreVFD (prop); h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, prop); @@ -42,7 +45,7 @@ main ( // create fake data for (int i = 0; i < DATASIZE; i++) { - data[i] = i + mpi_rank * DATASIZE; + data[i] = i + comm_rank * DATASIZE; } // write the data diff --git a/examples/H5Part/write_setnparticles.c b/examples/H5Part/write_setnparticles.c index 9c30e7f..6c45073 100644 --- a/examples/H5Part/write_setnparticles.c +++ b/examples/H5Part/write_setnparticles.c @@ -10,21 +10,26 @@ #include #include "H5hut.h" -#define FNAME "example_setnparticles.h5" -#define NUM_PARTICLES 3 +#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT + +#define FNAME "example_setnparticles.h5" +#define NUM_PARTICLES 3 int main ( int argc, char* argv[] ){ + h5_int64_t verbosity = DEFAULT_VERBOSITY; + // initialize MPI & H5hut MPI_Init (&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; int rank = 0; MPI_Comm_rank (comm, &rank); + H5AbortOnError (); - H5SetVerbosityLevel (-1); + H5SetVerbosityLevel (verbosity); // create fake data h5_int32_t data[NUM_PARTICLES]; diff --git a/examples/H5Part/write_setview.c b/examples/H5Part/write_setview.c index 2009965..3ad1981 100644 --- a/examples/H5Part/write_setview.c +++ b/examples/H5Part/write_setview.c @@ -10,28 +10,32 @@ #include #include "H5hut.h" -#define FNAME "example_setview.h5" -#define DATASIZE 32 -#define ITERS 4 +#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT + +#define FNAME "example_setview.h5" +#define DATASIZE 32 +#define ITERS 4 int main ( int argc, char** argv ) { + h5_int64_t verbosity = DEFAULT_VERBOSITY; // initialize MPI & H5hut MPI_Init (&argc, &argv); MPI_Comm comm = MPI_COMM_WORLD; - int mpi_rank = 0; - MPI_Comm_rank (comm, &mpi_rank); + int comm_rank = 0; + MPI_Comm_rank (comm, &comm_rank); H5AbortOnError (); + H5SetVerbosityLevel (verbosity); // create fake data h5_int64_t npoints = ITERS*DATASIZE; h5_int32_t data[ITERS*DATASIZE]; for (int i = 0; i < npoints; i++) { - data[i] = i + mpi_rank*npoints; + data[i] = i + comm_rank*npoints; } // open file and create step #0 @@ -43,7 +47,7 @@ main ( H5PartSetNumParticles(file, npoints); // write ITER consecutive blocks of size DATASIZE - h5_int64_t offset = mpi_rank * npoints; + h5_int64_t offset = comm_rank * npoints; for (int i = 0; i < ITERS; i++) { // set the "view" to select a subset of the dataset H5PartSetView ( diff --git a/examples/H5Part/write_strided.c b/examples/H5Part/write_strided.c index e4e656f..2e964e0 100644 --- a/examples/H5Part/write_strided.c +++ b/examples/H5Part/write_strided.c @@ -9,20 +9,26 @@ #include "H5hut.h" -#define FNAME "example_strided.h5" -#define NPOINTS 99 +#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT + +#define FNAME "example_strided.h5" +#define NPOINTS 99 int main ( int argc, char** argv ) { + h5_int64_t verbosity = DEFAULT_VERBOSITY; + // MPI & H5hut init MPI_Init (&argc, &argv); int rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Comm_rank (comm, &rank); + H5AbortOnError (); + H5SetVerbosityLevel (verbosity); // create fake data h5_float64_t particles[6*NPOINTS];