From d79d0ddf1afcc94bd3888b314d7abf1a2db98c64 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 15 Nov 2013 16:44:07 +0100 Subject: [PATCH] basic read_strided example implemented --- examples/H5Part/read_strided.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/H5Part/read_strided.c b/examples/H5Part/read_strided.c index e7162ad..6f91518 100644 --- a/examples/H5Part/read_strided.c +++ b/examples/H5Part/read_strided.c @@ -11,7 +11,7 @@ #define DEFAULT_VERBOSITY H5_VERBOSE_DEFAULT -#define FNAME "example_particles.h5" +#define FNAME "example_strided.h5" int main ( @@ -32,8 +32,21 @@ main ( H5SetStep (file, 0); - // TODO - + // Get number of particles in datasets and allocate memory + h5_int64_t num_particles = H5PartGetNumParticles (file); + h5_float64_t* data = calloc (6*num_particles, sizeof (*data)); + + // set number of particles and memory stride + H5PartSetNumParticlesStrided (file, num_particles, 6); + + // read data + H5PartReadDataFloat64 (file, "x", data+0); + H5PartReadDataFloat64 (file, "y", data+1); + H5PartReadDataFloat64 (file, "z", data+2); + H5PartReadDataFloat64 (file, "px", data+3); + H5PartReadDataFloat64 (file, "py", data+4); + H5PartReadDataFloat64 (file, "pz", data+5); + H5CloseFile (file); return MPI_Finalize (); }