This commit is contained in:
2008-02-13 15:16:47 +00:00
parent bc10ebd64e
commit 0222405291
3 changed files with 0 additions and 292 deletions
-2
View File
@@ -64,8 +64,6 @@ src/h5/t_openclose.c -text
src/h5/t_readwrite.c -text
src/h5/u_readwrite.c -text
src/h5/u_readwrite.h -text
test/H5PartAndreasTest.cc -text
test/H5testFpar.f90 -text
test/Makefile.am -text
test/h5b/BlockTestSpecs.txt -text
test/h5b/H5BlockDissolveGhosts.c -text
-119
View File
@@ -1,119 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <hdf5.h>
#include "H5Part.h"
/*
A simple regression test that shows how you use this API
to write and read multi-timestep files of particle data.
*/
#ifdef PARALLEL_IO
int main(int argc,char *argv[]){
int N = 10;
int sz=0;
double *x,*y,*z;
h5part_int64_t *id;
H5PartFile *file;
int i,t,nt,nds;
int nprocs,myproc;
unsigned int np = 0;
MPI_Comm comm=MPI_COMM_WORLD;
MPI_Init(&argc,&argv);
MPI_Comm_size(comm,&nprocs);
MPI_Comm_rank(comm,&myproc);
/* parallel file creation */
file=H5PartOpenFileParallel("parttest.h5",H5PART_WRITE,comm);
if(!file) {
perror("File open failed: exiting!");
exit(0);
}
for(t=0;t<5;t++){
MPI_Barrier(comm);
sz = myproc*N;
// proc[0] sz = 10, (next step N=10), sz=10
// proc[1] sz = 20, (next step N=20), sz=40
fprintf(stderr,"proc[%u] sz=%u\n",myproc,(unsigned)sz);
x =(double*)malloc(1+sz*sizeof(double));
y =(double*)malloc(1+sz*sizeof(double));
z =(double*)malloc(1+sz*sizeof(double));
id=(h5part_int64_t*)malloc(1+sz*sizeof(h5part_int64_t));
for(i=0;i<sz;i++) {
x[i]=(double)(i+t)+10.0*(double)myproc;
y[i]=0.1 + (double)(i+t);
z[i]=0.2 + (double)(i+t*10);
id[i]=i+sz*myproc;
}
fprintf(stderr,"Proc[%u] Writing timestep %u Np=%u\n",myproc,t,sz);
H5PartSetStep(file,t); /* must set the current timestep in file */
fprintf(stderr,"Proc[%u]: setNumParticles start\n",myproc);
H5PartSetNumParticles(file,sz); /* then set number of particles to store */
fprintf(stderr,"Proc[%u]: setNumParticles done\n",myproc);
/* now write different tuples of data into this timestep of the file */
fprintf(stderr,"Proc[%u]: WriteX start\n",myproc);
H5PartWriteDataFloat64(file,"x",x);
fprintf(stderr,"Proc[%u]: WriteX done\n",myproc);
H5PartWriteDataFloat64(file,"y",y);
H5PartWriteDataFloat64(file,"z",z);
H5PartWriteDataFloat64(file,"px",x);
H5PartWriteDataFloat64(file,"py",y);
H5PartWriteDataFloat64(file,"pz",z);
H5PartWriteDataInt64(file,"id",id);
if(x)
free(x);
if(y)
free(y);
if(z)
free(z);
if(id)
free(id);
// remove the next line and everything is ok
N = 1 + sz;
}
printf("AllDone p[%u]\n",myproc);
H5PartCloseFile(file);
MPI_Barrier(comm);
unsigned int idStart = 0;
unsigned int idEnd = myproc*10;
printf("p[%u:%u] : OK, close file and reopen for reading idStart %u idEnd %u \n",myproc,nprocs,idStart,idEnd);
file=H5PartOpenFileParallel("parttest.h5",H5PART_READ,comm);
H5PartSetStep(file,0);
nt = H5PartGetNumSteps(file); /* get number of steps in file */
nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */
MPI_Barrier(comm);
H5PartSetView(file,idStart,idEnd);
np = H5PartGetNumParticles(file);
printf("steps= %u datasets= %u particles= %u\n",nt,nds,np);
H5PartCloseFile(file);
MPI_Barrier(comm);
fprintf(stderr,"proc[%u]: done\n",myproc);
return MPI_Finalize();
}
#endif
-171
View File
@@ -1,171 +0,0 @@
! ==============
!
! Sample Fortran program that uses HDF5 bindings
!
! ==============
program H5testFpar
implicit none
include 'mpif.h'
include 'H5PartF90.inc'
INTEGER*8 file
INTEGER*8 nstep
INTEGER*8 ndata
INTEGER*8 npoints,pointoffset
INTEGER*8 I,J,K,step
REAL*8,ALLOCATABLE:: X(:),Y(:),Z(:),PX(:),PY(:),PZ(:)
INTEGER*8,ALLOCATABLE:: ID(:)
REAL*8 REALTIME(1)
INTEGER myproc,nprocs
INTEGER ierr
INTEGER*8 rc
INTEGER:: comm
INTEGER*8:: offset
INTEGER*8, allocatable, dimension(:,:) :: Localnum1
INTEGER*8, allocatable, dimension(:,:,:) :: Localnum
INTEGER nprocrow, nproccol
call MPI_Init(ierr)
comm = MPI_COMM_WORLD
call MPI_Comm_rank(comm,myproc,ierr)
call MPI_Comm_size(comm,nprocs,ierr)
file = h5pt_openw_par("testfilef.h5",comm)
print *,"Opened file testfilef.h5 for writing"
npoints = 1024
nstep = 10
ALLOCATE(X(npoints),Y(npoints),Z(npoints))
ALLOCATE(PX(npoints),PY(npoints),PZ(npoints))
ALLOCATE(ID(npoints))
print *," Npoints=",npoints," nsteps=",nstep
print *," writing X,Y,Z,PX,PY,PZ,ID"
print *," ... initialize the data arrays"
do I=1,npoints
X(INT(I))=0.0
Y(I)=1.0+REAL(I)
Z(I)=100.0+REAL(I)*2.0
ID(I)=I
enddo
print *,"Tell h5pt how many particles are stored in the file"
! set the number of points
rc = h5pt_setnpoints(file,npoints)
print *,"write an attribute string"
! write an annotation to the file
rc=h5pt_writefileattrib_string(file,"Annotation","Testing 1 2 3")
print *,"and now write the steps"
do step=1,nstep
! Set the step number
print *,"Write Step ",step
rc = h5pt_setstep(file,step)
! Now start writing the data arrays for this step
rc = h5pt_writedata_r8(file,"x",X)
rc = h5pt_writedata_r8(file,"y",Y)
rc = h5pt_writedata_r8(file,"z",Z)
rc = h5pt_writedata_r8(file,"px",PX)
rc = h5pt_writedata_r8(file,"py",PY)
rc = h5pt_writedata_r8(file,"pz",PZ)
rc = h5pt_writedata_i8(file,"id",ID)
do J=1,npoints
ID(J)=ID(J)+10
enddo
! And write a simple floatingpoint attribute associated with this timestep
REALTIME(1) = REAL(I)*0.1
rc = h5pt_writestepattrib_r8(file,"RealTime",REALTIME,1_8)
print*,'Write REALTIME ',REALTIME
!
! Test file arrtibutes
!
nprocrow=2
nproccol=2
print*,'Write localnum ',Localnum
allocate(Localnum1(1,nprocrow*nproccol))
allocate(Localnum(2,0:nprocrow-1,0:nproccol-1))
!
! init testdata
!
do k = 0, 1
do i = 0,(nprocrow-1)
do j = 0,(nproccol-1)
Localnum(k,i,j) = k+i+j
enddo
enddo
enddo
!
offset=0
do i = 0, (nprocrow-1)
do j = 0,(nproccol-1)
Localnum1(offset) = Localnum(1,i,j)
offset = offset + 1
enddo
enddo
rc = h5pt_writestepattrib_i8(file,"Localnum1",Localnum1(:),offset)
print*,'rc (Localnum1)= ',rc
enddo
print *,"Done writing, now close the file"
rc = h5pt_close(file)
! **************** Clean out some variables ***************
nstep=0
! npoints=0
do I=1,npoints
X(I)=-1.0
Y(I)=-1.0
Z(I)=-1.0
ID(I)=0
enddo
do k = 0, 1
do i = 0,(nprocrow-1)
do j = 0,(nproccol-1)
Localnum(k,i,j) = 0
enddo
enddo
enddo
REALTIME(1) = 0.0
! *****************Now Reopen for Reading ******************
print *,"Open file for reading"
file = h5pt_openr_par("testfilef.h5",comm)
print *," Opened testfilef.h5"
nstep = h5pt_getnsteps(file)
print *," Nsteps = ",nstep
rc = h5pt_setstep(file,1_8)
print *,"now get the number of datasets"
ndata = h5pt_getndatasets(file)
print *," Ndata=",ndata
npoints = h5pt_getnpoints(file)
print *," Total NP=",npoints
npoints = npoints/nprocs
pointoffset = npoints*myproc;
rc = h5pt_setview(file,pointoffset,pointoffset+npoints)
print *," Pointoffset=",pointoffset," Local NP=",npoints
! Now we need to set our view to read correct points
do step=1,nstep
print *,"Read step ",step
! set the current step
rc = h5pt_setstep(file,step)
rc = h5pt_readdata_i8(file,"id",ID)
rc = h5pt_readstepattrib_r8(file,"RealTime",REALTIME)
print*,'Read REALTIME ',REALTIME
rc = h5pt_readstepattrib_i8(file,"Localnum1",Localnum1)
print*,'Read Localnum ',Localnum1
! read the Z data from the current step
! rc = h5prt_readdata(file,step,X,Y,Z,PX,PY,PZ,ID)
! do J=1,10
! print *," ID(",J,")==",ID(J)
! enddo
enddo
rc = h5pt_close(file)
print *,"done"
call MPI_Finalize(ierr)
end