#include #include #include #include #include "H5Part++.hh" #include #include #include #include using namespace std; #ifdef READTEST /* A simple regression test that shows how you use this API to write and read multi-timestep files of particle data. */ #ifdef PARALLEL_IO #else int main(int argc,char **argv){ const int sz=5; double x[sz],y[sz],z[sz]; long long id[sz]; char name[64]; H5PartFile *file; int i,t,nt,nds,myproc; int nfattribs,nsattribs; const string fn = string(argv[1]); cout << "Open " << fn << endl; file= H5PartOpenFile(fn.c_str(),H5PART_READ); nt=H5PartGetNumSteps(file); /* get number of steps in file */ H5PartSetStep(file,0); nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */ puts("\n\n==============================="); for(i=0;ifile); H5PartSetStep(file,t); /* must set the current timestep in file */ H5PartSetNumParticles(file,sz); /* then set number of particles to store */ /* now write different tuples of data into this timestep of the file */ H5PartWriteDataFloat64(file,"x",x); H5PartWriteDataFloat64(file,"y",y); H5PartWriteDataFloat64(file,"z",z); H5PartWriteDataInt64(file,"id",id); } printf("AllDone p[%u]\n",myproc); H5PartCloseFile(file); MPI_Barrier(comm); printf("p[%u:%u] : OK, close file and reopen for reading \n",myproc,nprocs); if(myproc==0){ /* now only proc 0 reads the file serially */ file= H5PartOpenFileSerial("parttest.h5",H5PART_READ); nt=H5PartGetNumSteps(file); /* get number of steps in file */ H5PartSetStep(file,0); nds=H5PartGetNumDatasets(file); /* get number of datasets in timestep 0 */ puts("\n\n==============================="); for(i=0;i0){ char attrname[32]; H5PartGetStepAttribInfo(file,0,attrname,32,0,0); printf("First Attrib name is [%s]\n",attrname); } H5PartReadParticleStep(file,t,/* do a mongo read of all data this step */ x,y,z,id); printf("\tid\t\tx\t\ty\t\tz\n"); puts("\t----------------------------------------------------"); for(i=0;i