examples/H5Part

- reviewed
This commit is contained in:
2015-09-08 20:53:07 +02:00
parent ec3a29d7e4
commit 106be817d9
15 changed files with 461 additions and 335 deletions
+21 -19
View File
@@ -7,44 +7,46 @@
License: see file COPYING in top level of source distribution.
*/
#include <stdlib.h>
#include "H5hut.h"
#define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT
// name of output file
const char* fname = "example_setnparticles.h5";
#define FNAME "example_setnparticles.h5"
#define NUM_PARTICLES 3
// H5hut verbosity level
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
// number of particles we are going to write per core
const h5_int64_t num_particles = 99;
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);
int comm_size = 1;
MPI_Comm_size (comm, &comm_size);
int comm_rank = 0;
MPI_Comm_rank (comm, &comm_rank);
H5AbortOnError ();
H5SetVerbosityLevel (verbosity);
H5SetVerbosityLevel (h5_verbosity);
// create fake data
h5_int32_t data[NUM_PARTICLES];
h5_int64_t num_particles = NUM_PARTICLES;
for (int i = 0; i < num_particles; i++) {
data[i] = i + num_particles * rank;
}
// open file and create step #0
h5_file_t file = H5OpenFile (FNAME, H5_O_WRONLY, H5_PROP_DEFAULT);
// open file and create first step
h5_file_t file = H5OpenFile (fname, H5_O_WRONLY, H5_PROP_DEFAULT);
H5SetStep (file, 0);
// define number of items this process will write
// define number of particles this process will write
H5PartSetNumParticles (file, num_particles);
// create fake data
h5_int32_t data[num_particles];
for (int i = 0; i < num_particles; i++) {
data[i] = i + num_particles * comm_rank;
}
// write data
H5PartWriteDataInt32 (file, "data", data);