#include #include "H5hut.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 sz=5; double *x,*y,*z; h5_int64_t *id; h5_file_t *file; int i,t,nt,nds; int nprocs,myproc; MPI_Comm comm=MPI_COMM_WORLD; MPI_Init(&argc,&argv); MPI_Comm_size(comm,&nprocs); MPI_Comm_rank(comm,&myproc); x=(double*)malloc(sz*nprocs*sizeof(double)); y=(double*)malloc(sz*nprocs*sizeof(double)); z=(double*)malloc(sz*nprocs*sizeof(double)); id=(h5_int64_t*)malloc(sz*nprocs*sizeof(h5_int64_t)); /* parallel file creation */ file=H5OpenFile ("parttest.h5",H5_O_WRONLY,comm); if(!file) { perror("File open failed: exiting!"); exit(0); } for(t=0;t<5;t++){ MPI_Barrier(comm); for(i=0;i>1); printf("Set new view = %d:%d\n",(int)idStart,(int)(idEnd>>1)); H5PartGetView(file,&idStart,&idEnd); np=H5PartGetNumParticles(file); printf("steps= %u datasets= %u particles= %d with view %d:%d\n", nt,nds,(int)np,(int)idStart,(int)idEnd); H5PartSetStep(file,nt-1); // set to last step printf("Setting to last step = %u\n",nt-1); for(i=0;i<10;i++){ x[i]=y[i]=z[i]=0.0; id[i]=0; } /* clear the arrays */ H5PartReadDataFloat64(file,"x",x); H5PartReadDataFloat64(file,"y",y); H5PartReadDataFloat64(file,"z",z); H5PartReadDataInt64(file,"id",id); for(i=0;i>1,(int)idEnd); H5PartSetView(file,(idEnd>>1),idEnd); np=H5PartGetNumParticles(file); printf("Now particles in selection are %d\n",np); printf("doubleCheck=%lld\n", (long long)H5PartGetView(file,0,0)); for(i=0;i<10;i++){ x[i]=y[i]=z[i]=0.0; id[i]=0; } /* clear the arrays */ H5PartReadDataFloat64(file,"x",x); H5PartReadDataFloat64(file,"y",y); H5PartReadDataFloat64(file,"z",z); H5PartReadDataInt64(file,"id",id); for(i=0;i