examples/H5Part/*
- cleanup and fixes
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
read_core_vfd
|
||||
read_core_vfdf
|
||||
read_canonicalviewf
|
||||
read_setnparticlesf
|
||||
read_setviewf
|
||||
|
||||
@@ -27,7 +27,7 @@ program read_canonicalview
|
||||
|
||||
! initialize MPI & H5hut
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_error)
|
||||
call mpi_init (mpi_ierror)
|
||||
call mpi_comm_size (comm, comm_size, mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
call h5_abort_on_error ()
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (c) 2006-2015, The Regents of the University of California,
|
||||
through Lawrence Berkeley National Laboratory (subject to receipt of any
|
||||
required approvals from the U.S. Dept. of Energy) and the Paul Scherrer
|
||||
Institut (Switzerland). All rights reserved.
|
||||
|
||||
License: see file COPYING in top level of source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
Note:
|
||||
Running this example on more than one core is possible but the result
|
||||
might not be what you expect. Please read the HDF5 documentation about
|
||||
the VFD core driver.
|
||||
*/
|
||||
#include "H5hut.h"
|
||||
|
||||
// name of input file
|
||||
const char* fname = "example_core_vfd.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
int
|
||||
main (
|
||||
int argc,
|
||||
char* argv[]
|
||||
){
|
||||
|
||||
// initialize MPI & H5hut
|
||||
MPI_Init (&argc, &argv);
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
int comm_size = 1;
|
||||
MPI_Comm_size (comm, &comm_size);
|
||||
int comm_rank = 0;
|
||||
MPI_Comm_rank (comm, &comm_rank);
|
||||
H5AbortOnError ();
|
||||
H5SetVerbosityLevel (h5_verbosity);
|
||||
|
||||
// open file and create first step
|
||||
h5_prop_t prop = H5CreateFileProp ();
|
||||
H5SetPropFileCoreVFD (prop);
|
||||
h5_file_t file = H5OpenFile (fname, H5_O_RDONLY, prop);
|
||||
H5SetStep (file, 0);
|
||||
|
||||
// with core cfd we read the hole file on all cores!
|
||||
h5_int64_t num_particles = H5PartGetNumParticles (file);
|
||||
printf ("[proc %d]: particles in view: %lld\n", comm_rank, num_particles);
|
||||
|
||||
// read and print data
|
||||
h5_int32_t* data = calloc (num_particles, sizeof (*data));
|
||||
H5PartReadDataInt32 (file, "data", data);
|
||||
for (int i = 0; i < num_particles; i++) {
|
||||
printf ("[proc %d]: local index = %d, value = %d\n",
|
||||
comm_rank, i, data[i]);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
free (data);
|
||||
H5CloseFile (file);
|
||||
return MPI_Finalize ();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
!
|
||||
! Copyright (c) 2006-2015, The Regents of the University of California,
|
||||
! through Lawrence Berkeley National Laboratory (subject to receipt of any
|
||||
! required approvals from the U.S. Dept. of Energy) and the Paul Scherrer
|
||||
! Institut (Switzerland). All rights reserved.!
|
||||
!
|
||||
! License: see file COPYING in top level of source distribution.
|
||||
!
|
||||
include 'H5hut.f90'
|
||||
|
||||
program read_core_vfd
|
||||
use H5hut
|
||||
implicit none
|
||||
include 'mpif.h'
|
||||
|
||||
! name of input file
|
||||
character (len=*), parameter :: fname = "example_core_vfd.h5"
|
||||
|
||||
! H5hut verbosity level
|
||||
integer*8, parameter :: h5_verbosity = H5_VERBOSE_DEFAULT
|
||||
|
||||
|
||||
integer :: comm, comm_size, comm_rank, mpi_ierror
|
||||
integer*8 :: file, h5_ierror
|
||||
integer*8 :: prop
|
||||
integer*8 :: num_particles
|
||||
integer*4 :: i
|
||||
integer*4, allocatable :: data(:)
|
||||
|
||||
! initialize MPI & H5hut
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_ierror)
|
||||
call mpi_comm_size (comm, comm_size, mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
call h5_abort_on_error ()
|
||||
call h5_set_verbosity_level (h5_verbosity)
|
||||
|
||||
! open file and create first step
|
||||
prop = h5_createprop_file ()
|
||||
h5_ierror = h5_setprop_file_corevfd (prop);
|
||||
file = h5_openfile (fname, H5_O_RDONLY, prop)
|
||||
h5_ierror = h5_setstep(file, 1_8)
|
||||
|
||||
! with core cfd we read the hole file on all cores!
|
||||
num_particles = h5pt_getnpoints (file)
|
||||
write (*, "('[proc ', i4, ']: particles in view: ', i4)") &
|
||||
comm_rank, num_particles
|
||||
|
||||
! read and print data
|
||||
allocate (data (num_particles))
|
||||
h5_ierror = h5pt_readdata_i4 (file, "data", data)
|
||||
do i = 1, int (num_particles)
|
||||
write (*, "('[proc ', i4, ']: local index = ', i4, ', value = ', i4)") &
|
||||
comm_rank, i, data(i)
|
||||
end do
|
||||
|
||||
! cleanup
|
||||
deallocate (data)
|
||||
h5_ierror = h5_closefile (file)
|
||||
call mpi_finalize (mpi_ierror)
|
||||
|
||||
end program read_core_vfd
|
||||
@@ -40,8 +40,9 @@ main (
|
||||
if (comm_rank+1 == comm_size)
|
||||
num_particles += num_particles_total % comm_size;
|
||||
|
||||
h5_info ("Total number of particles: %lld", (long long unsigned)num_particles_total);
|
||||
h5_info ("Number of particles on this core: %lld", (long long unsigned)num_particles);
|
||||
printf ("[proc %d]: particles in view: %lld\n", comm_rank, num_particles);
|
||||
printf ("[proc %d]: total number of particles: %lld\n",
|
||||
comm_rank, (long long unsigned)num_particles_total);
|
||||
|
||||
H5PartSetNumParticles (file, num_particles);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ program read_setnparticles
|
||||
|
||||
! initialize MPI & H5hut
|
||||
comm = MPI_COMM_WORLD
|
||||
call mpi_init (mpi_error)
|
||||
call mpi_init (mpi_ierror)
|
||||
call mpi_comm_size (comm, comm_size, mpi_ierror)
|
||||
call mpi_comm_rank (comm, comm_rank, mpi_ierror)
|
||||
call h5_abort_on_error ()
|
||||
@@ -35,7 +35,7 @@ program read_setnparticles
|
||||
|
||||
! open file and go to first step
|
||||
file = h5_openfile (fname, H5_O_RDONLY, H5_PROP_DEFAULT)
|
||||
h5_ierror = h5_setstep(file, 1_8)
|
||||
h5_ierror = h5_setstep (file, 1_8)
|
||||
|
||||
! compute and set number of particles this process has to read
|
||||
num_particles_total = h5pt_getnpoints (file)
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
const char* fname = "example_strided.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
//const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
const h5_int64_t h5_verbosity = H5_DEBUG_ALL;
|
||||
|
||||
int
|
||||
main (
|
||||
@@ -38,7 +39,7 @@ main (
|
||||
h5_int64_t num_particles = H5PartGetNumParticles (file);
|
||||
|
||||
// set number of particles and memory stride
|
||||
H5PartSetNumParticlesStrided (file, num_particles, 6);
|
||||
H5PartSetNumParticlesStrided (file, 98, 6);
|
||||
|
||||
// read data
|
||||
h5_float64_t* data = calloc (6*num_particles, sizeof (*data));
|
||||
@@ -50,7 +51,7 @@ main (
|
||||
H5PartReadDataFloat64 (file, "pz", data+5);
|
||||
|
||||
// print dataset "x"
|
||||
for (int i = 0; i < num_particles; i+=6) {
|
||||
for (int i = 0; i < num_particles*6; i+=1) {
|
||||
printf ("[proc %d]: local index = %d, value = %6.3f\n",
|
||||
comm_rank, i, data[i]);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
const char* fname = "example_setview.h5";
|
||||
|
||||
// H5hut verbosity level
|
||||
const h5_int64_t h5_verbosity = H5_DEBUG_ALL;
|
||||
const h5_int64_t h5_verbosity = H5_VERBOSE_DEFAULT;
|
||||
|
||||
// we are going to write multiple consecutive blocks
|
||||
const h5_int64_t num_blocks = 4;
|
||||
|
||||
@@ -17,7 +17,7 @@ program write_setview
|
||||
character (len=*), parameter :: fname = "example_setview.h5"
|
||||
|
||||
! H5hut verbosity level
|
||||
integer*8, parameter :: h5_verbosity = H5_DEBUG_ALL
|
||||
integer*8, parameter :: h5_verbosity = H5_VERBOSE_DEFAULT
|
||||
|
||||
! we are going to write multiple consecutive blocks
|
||||
integer*8, parameter :: num_blocks = 4;
|
||||
|
||||
Reference in New Issue
Block a user