src/addToDoxygenMainPage.h
- removed (content moved to "H5Part.c") test/H5ecloudExample.cc src/H5Units.h src/H5Part.cc src/H5Part++.hh src/H5Part.hh src/H5Part++.cc tools/h5pToGNUplot.py - removed doc/Makefile.am - added doc/H5tools/H5tools.htm - renamed to "doc/H5tools/H5tools.html"
This commit is contained in:
+2
-9
@@ -28,9 +28,10 @@ doc/H5PartVisIt/cloud_visit_2D.png -text
|
||||
doc/H5PartVisIt/cloud_visit_2D.s.png -text
|
||||
doc/H5PartVisIt/visit_query1.png -text
|
||||
doc/H5PartVisIt/visit_query1.s.png -text
|
||||
doc/H5tools/H5tools.htm -text
|
||||
doc/H5tools/H5tools.html -text
|
||||
doc/H5tools/H5tools_files/snapshot1.jpg -text
|
||||
doc/InternalLayout.html -text
|
||||
doc/Makefile.am -text
|
||||
doc/UsingC.html -text
|
||||
doc/UsingF.html -text
|
||||
doc/collision_6.png -text
|
||||
@@ -49,22 +50,16 @@ src/H5BlockF.c -text
|
||||
src/H5BlockF90.inc -text
|
||||
src/H5BlockPrivate.h -text
|
||||
src/H5BlockTypes.h -text
|
||||
src/H5Part++.cc -text
|
||||
src/H5Part++.hh -text
|
||||
src/H5Part.c -text
|
||||
src/H5Part.cc -text
|
||||
src/H5Part.h -text
|
||||
src/H5Part.hh -text
|
||||
src/H5PartErrors.h -text
|
||||
src/H5PartF.c -text
|
||||
src/H5PartF90.inc -text
|
||||
src/H5PartPrivate.h -text
|
||||
src/H5PartTypes.h -text
|
||||
src/H5Units.h -text
|
||||
src/Makefile.am -text
|
||||
src/TestUnderscore.f -text
|
||||
src/TestUnderscoreC.c -text
|
||||
src/addToDoxygenMainPage.h -text
|
||||
test/Bench.c -text
|
||||
test/BlockTestSpecs.txt -text
|
||||
test/H5BlockDissolveGhosts.c -text
|
||||
@@ -77,7 +72,6 @@ test/H5ParallelTest.cc -text
|
||||
test/H5PartAndreasTest.cc -text
|
||||
test/H5PartTest.cc -text
|
||||
test/H5PartTestParallel.cc -text
|
||||
test/H5ecloudExample.cc -text
|
||||
test/H5test.cc -text
|
||||
test/H5testF.f -text
|
||||
test/H5testFpar.f90 -text
|
||||
@@ -86,7 +80,6 @@ tools/Makefile.am -text
|
||||
tools/README -text
|
||||
tools/h5pAttrib.cc -text
|
||||
tools/h5pToGNUplot.cc -text
|
||||
tools/h5pToGNUplot.py -text
|
||||
visit_plugins/databases/H5Part/.depend -text
|
||||
visit_plugins/databases/H5Part/Makefile -text
|
||||
visit_plugins/databases/H5Part/README.txt -text
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
EXTRA_DIST = \
|
||||
Doxyfile doxyfooter \
|
||||
$(wildcard *.html) \
|
||||
$(wildcard *.png) \
|
||||
$(wildcard H5PartVisIt/*.png) \
|
||||
$(wildcard H5tools/*.html) \
|
||||
$(wildcard H5tools/H5tools_files/*.jpg)
|
||||
-234
@@ -1,234 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5Part++.hh"
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
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;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
|
||||
nfattribs=H5PartGetNumFileAttribs(file);
|
||||
printf("Number of datasteps in file is %u num file attribs=%d\n",
|
||||
nt,nfattribs);
|
||||
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef REGRESSIONTEST
|
||||
|
||||
/*
|
||||
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;
|
||||
long long *id;
|
||||
char name[64];
|
||||
H5PartFile *file;
|
||||
int i,t,nt,nds;
|
||||
int nprocs,myproc;
|
||||
hid_t gid;
|
||||
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=(long long*)malloc(sz*nprocs*sizeof(long long));
|
||||
/* 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);
|
||||
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;
|
||||
}
|
||||
printf("Proc[%u] Writing timestep %u file=%u\n",myproc,t,file->file);
|
||||
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;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
printf("Number of datasteps in file is %u\n",nt);
|
||||
for(t=0;t<nt;t++){
|
||||
int nparticles;
|
||||
H5PartSetStep(file,t); /* select a timestep */
|
||||
nparticles=(int)H5PartGetNumParticles(file);
|
||||
printf("Step[%u] nparticles this step=%u\n",
|
||||
t,nparticles); /* get num particles this step *
|
||||
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<nparticles;i++) {
|
||||
printf("\t%llu\t%f\t%f\t%f\n\n",id[i],x[i],y[i],z[i]);
|
||||
}
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
if(x) free(x);
|
||||
if(y) free(y);
|
||||
if(z) free(z);
|
||||
if(id) free(id);
|
||||
MPI_Barrier(comm);
|
||||
fprintf(stderr,"proc[%u]: done\n",myproc);
|
||||
return MPI_Finalize();
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
file=H5PartOpenFile("parttest.h5",H5PART_WRITE);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
for(t=0;t<5;t++){
|
||||
long long step=t;
|
||||
printf("Writing timestep %u\n",t);
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t);
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t);
|
||||
id[i]=i;
|
||||
}
|
||||
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);
|
||||
H5PartWriteStepAttrib(file,"Step",H5T_NATIVE_INT64,&step,1);
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
printf("OK, close file and reopen for reading\n");
|
||||
file= H5PartOpenFile("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;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
|
||||
nfattribs=H5PartGetNumFileAttribs(file);
|
||||
printf("Number of datasteps in file is %u num file attribs=%d\n",
|
||||
nt,nfattribs);
|
||||
for(t=0;t<nt;t++){
|
||||
int nparticles;
|
||||
H5PartSetStep(file,t); /* select a timestep */
|
||||
nparticles=(int)H5PartGetNumParticles(file);
|
||||
nsattribs=H5PartGetNumStepAttribs(file);
|
||||
printf("Step[%u] nparticles this step=%u stepattribs=%u\n",
|
||||
t,nparticles,nsattribs); /* get num particles this step */
|
||||
if(nsattribs>0){
|
||||
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<sz;i++) {
|
||||
printf("\t%llu\t%f\t%f\t%f\n\n",id[i],x[i],y[i],z[i]);
|
||||
}
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
-219
@@ -1,219 +0,0 @@
|
||||
#ifndef _H5Part_HH_
|
||||
#define _H5Part_HH_
|
||||
|
||||
extern "C" {
|
||||
#include "H5Part.h"
|
||||
#ifdef PARALLEL_IO
|
||||
#include <mpi.h>
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Add any C++ specific extensions/implementations/wrappers here */
|
||||
|
||||
/* here is a sample class wrapping of H5Part for C++ usage */
|
||||
|
||||
class H5ParticleFile {
|
||||
H5PartFile *file;
|
||||
long long np;
|
||||
public:
|
||||
H5ParticleFile(const char *filename,const int flags):np(0){
|
||||
this->file=H5PartOpenFile(filename,flags);
|
||||
}
|
||||
|
||||
// H5ParticleFile(const std::string fn,const int flags):np(0){
|
||||
// this->file=H5PartOpenFile(fn.cstr(),flags);
|
||||
//}
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
H5ParticleFile(const char *filename,const int flags,const MPI_Comm comm):np(0){
|
||||
this->file=H5PartOpenFileParallel(filename,flags,comm);
|
||||
}
|
||||
// H5ParticleFile(const string fn,const int flags,const MPI_Comm comm):np(0){
|
||||
// this->file=H5PartOpenFile(fn.cstr(),flags,comm);
|
||||
//}
|
||||
#endif
|
||||
inline int isValid() { return H5PartFileIsValid(this->file);}
|
||||
|
||||
~H5ParticleFile(){H5PartCloseFile(this->file);}
|
||||
|
||||
inline void setNumParticles(long long nparticles){
|
||||
np=nparticles;
|
||||
H5PartSetNumParticles(file,nparticles);
|
||||
}
|
||||
// get the current step (-1 means step is invalid)
|
||||
inline int step(){ return file->timestep; }
|
||||
// set the current step
|
||||
inline int step(int s){ H5PartSetStep(this->file,s); return file->timestep; }
|
||||
inline int nSteps(){ return H5PartGetNumSteps(this->file);}
|
||||
inline int nFields(){ return H5PartGetNumDatasets(file);}
|
||||
inline int fieldName(int index,char *name,int maxlen){H5PartGetDatasetName(file,index,name,maxlen);}
|
||||
inline long long nParticles(){return H5PartGetNumParticles(file);}
|
||||
inline int write(char *name,double *array){
|
||||
return H5PartWriteDataFloat64(this->file,name,array);
|
||||
}
|
||||
inline int write(char *name,long long *array){
|
||||
return H5PartWriteDataInt64(this->file,name,array);
|
||||
}
|
||||
inline int read(char *name,double *array){
|
||||
return H5PartReadDataFloat64(this->file,name,array);
|
||||
}
|
||||
inline int read(char *name,long long *array){
|
||||
return H5PartReadDataInt64(this->file,name,array);
|
||||
}
|
||||
inline int readStep(int step,
|
||||
double *x,double *y,double *z,
|
||||
double *px,double *py,double *pz,
|
||||
long long *id){
|
||||
return H5PartReadParticleStep(file,step,
|
||||
x,y,z,
|
||||
px,py,pz,
|
||||
id);
|
||||
}
|
||||
|
||||
// Attribute stuff
|
||||
// Info on attributes
|
||||
inline int nStepAttribs(){ return H5PartGetNumStepAttribs(file);}
|
||||
inline void getStepAttribInfo(int idx,char *name,size_t maxsize,
|
||||
hid_t &type,int &nelem){
|
||||
H5PartGetStepAttribInfo(file,idx,name,maxsize,&type,&nelem);
|
||||
}
|
||||
inline int nFileAttribs(){ return H5PartGetNumFileAttribs(file);}
|
||||
inline void getFileAttribInfo(int idx,char *name,size_t maxsize,
|
||||
hid_t &type,int &nelem){
|
||||
H5PartGetFileAttribInfo(file,idx,name,maxsize,&type,&nelem);
|
||||
}
|
||||
// step attribs
|
||||
// int writeStepAttrib(char *key,string *valuestring){
|
||||
// return H5PartWriteStepAttribString(file,key,valuestring.c_str());
|
||||
//}
|
||||
inline int writeStepAttrib(char *key,char *valuestring){
|
||||
return H5PartWriteStepAttribString(file,key,valuestring);
|
||||
}
|
||||
inline int writeStepAttrib(char *key,double *value,int nelem=1){
|
||||
return H5PartWriteStepAttrib(file,key,H5T_NATIVE_DOUBLE,value,nelem);
|
||||
}
|
||||
inline int writeStepAttrib(char *key,float *value,int nelem=1){
|
||||
return H5PartWriteStepAttrib(file,key,H5T_NATIVE_FLOAT,value,nelem);}
|
||||
inline int writeStepAttrib(char *key,int *value,int nelem=1){
|
||||
return H5PartWriteStepAttrib(file,key,H5T_NATIVE_INT,value,nelem);}
|
||||
inline int writeStepAttrib(char *key,long long *value,int nelem=1){
|
||||
return H5PartWriteStepAttrib(file,key,H5T_NATIVE_INT64,value,nelem);}
|
||||
inline void readStepAttrib(char *key,void *value){
|
||||
H5PartReadStepAttrib(file,key,value);
|
||||
}
|
||||
// FileAttribs
|
||||
// Attribute stuff
|
||||
// int writeFileAttrib(char *key,string *valuestring){
|
||||
// return H5PartWriteFileAttribString(file,key,valuestring.c_str());
|
||||
//}
|
||||
inline int writeFileAttrib(char *key,char *valuestring){
|
||||
return H5PartWriteFileAttribString(file,key,valuestring);
|
||||
}
|
||||
inline int writeFileAttrib(char *key,double *value,int nelem=1){
|
||||
return H5PartWriteFileAttrib(file,key,H5T_NATIVE_DOUBLE,value,nelem);
|
||||
}
|
||||
inline int writeFileAttrib(char *key,float *value,int nelem=1){
|
||||
return H5PartWriteFileAttrib(file,key,H5T_NATIVE_FLOAT,value,nelem);}
|
||||
inline int writeFileAttrib(char *key,int *value,int nelem=1){
|
||||
return H5PartWriteFileAttrib(file,key,H5T_NATIVE_INT,value,nelem);}
|
||||
inline int writeFileAttrib(char *key,long long *value,int nelem=1){
|
||||
return H5PartWriteFileAttrib(file,key,H5T_NATIVE_INT64,value,nelem);}
|
||||
// read file attribs
|
||||
inline int readFileAttrib(char *key,void *valuestring){
|
||||
H5PartReadFileAttrib(file,key,valuestring);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
An even wackier idea
|
||||
file.datasets[0:ndatasets-1]
|
||||
file.attributes[0:nfileattribs-1]
|
||||
file.datasets.attributes[0:ndatasetattribs-1]
|
||||
file.datasets.size()
|
||||
|
||||
operators
|
||||
.size()
|
||||
.name()
|
||||
[idx]
|
||||
["name" or "keyname"]
|
||||
|
||||
*/
|
||||
#if 0
|
||||
|
||||
class H5Dataset {
|
||||
const hid_t dataset;
|
||||
char *n; // return as const
|
||||
int d[5]; // simple start
|
||||
int nd;
|
||||
public:
|
||||
H5Dataset(const hid_t ds_handle):dataset(ds_handle){}
|
||||
const char *name() {return n;}
|
||||
int nDims(){ return nd; }
|
||||
const int *dims(){return d;}
|
||||
};
|
||||
|
||||
class H5Attribute{
|
||||
char *n;
|
||||
int sz;
|
||||
public:
|
||||
const char *name(){return n;}
|
||||
int size(){return sz;}
|
||||
}
|
||||
|
||||
|
||||
class H5Group {
|
||||
hid_t gid;
|
||||
int sz;
|
||||
protected:
|
||||
virtual int computesize(){}
|
||||
void setGroup(gid_t g){
|
||||
if(gid>0) H5close(gid);
|
||||
gid=g;
|
||||
// must compute size if available
|
||||
if(gid>0) computesize();
|
||||
else sz=0;
|
||||
}
|
||||
public:
|
||||
// const hid_t gid;
|
||||
H5Group(hid_t g):gid(g){}
|
||||
H5Group():gid(-1){}
|
||||
~H5Group(){if(gid>0) H5Gclose(gid);}
|
||||
int size(){return sz;}
|
||||
};
|
||||
|
||||
class H5AttribGroup : public H5Group{
|
||||
int size;
|
||||
virtual void computesize(){
|
||||
// compute the number of items in this group
|
||||
}
|
||||
public:
|
||||
const H5Attribute &operator[](char *name);
|
||||
const H5Attribute &operator[](int idx);
|
||||
};
|
||||
|
||||
class H5DataGroup : public H5Group {
|
||||
int size;
|
||||
public:
|
||||
const H5Dataset &operator[](int idx);
|
||||
const H5Dataset &operator[](char *name);
|
||||
// no name here??
|
||||
};
|
||||
|
||||
class H5FancyParticles {
|
||||
char *n;
|
||||
hid_t file;
|
||||
public:
|
||||
hid_t mygroup;
|
||||
const H5AttribGroup attributes;
|
||||
const H5DataGroup datasets;
|
||||
H5FancyParticles(char *filename,int readwriteflag);
|
||||
~H5FancyParticles();
|
||||
// int size();// return the number of datasets in file
|
||||
// const char *name(); // return the name of the file?
|
||||
// const H5Dataset &operator[](int idx); // index dataset by integer
|
||||
// const H5Dataset &operator[](char *n); // index dataset by name
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
-234
@@ -1,234 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <hdf5.h>
|
||||
#include "H5Part.hh"
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
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;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
|
||||
nfattribs=H5PartGetNumFileAttribs(file);
|
||||
printf("Number of datasteps in file is %u num file attribs=%d\n",
|
||||
nt,nfattribs);
|
||||
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef REGRESSIONTEST
|
||||
|
||||
/*
|
||||
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;
|
||||
long long *id;
|
||||
char name[64];
|
||||
H5PartFile *file;
|
||||
int i,t,nt,nds;
|
||||
int nprocs,myproc;
|
||||
hid_t gid;
|
||||
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=(long long*)malloc(sz*nprocs*sizeof(long long));
|
||||
/* 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);
|
||||
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;
|
||||
}
|
||||
printf("Proc[%u] Writing timestep %u file=%u\n",myproc,t,file->file);
|
||||
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;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
printf("Number of datasteps in file is %u\n",nt);
|
||||
for(t=0;t<nt;t++){
|
||||
int nparticles;
|
||||
H5PartSetStep(file,t); /* select a timestep */
|
||||
nparticles=(int)H5PartGetNumParticles(file);
|
||||
printf("Step[%u] nparticles this step=%u\n",
|
||||
t,nparticles); /* get num particles this step */
|
||||
H5PartReadParticleStep(file,t, /* do a mongo read of all data this step */
|
||||
x,y,z,x,y,z,id);
|
||||
printf("\tid\t\tx\t\ty\t\tz\n");
|
||||
puts("\t----------------------------------------------------");
|
||||
for(i=0;i<nparticles;i++) {
|
||||
printf("\t%llu\t%f\t%f\t%f\n\n",id[i],x[i],y[i],z[i]);
|
||||
}
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
if(x) free(x);
|
||||
if(y) free(y);
|
||||
if(z) free(z);
|
||||
if(id) free(id);
|
||||
MPI_Barrier(comm);
|
||||
fprintf(stderr,"proc[%u]: done\n",myproc);
|
||||
return MPI_Finalize();
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
file=H5PartOpenFile("parttest.h5",H5PART_WRITE);
|
||||
if(!file) {
|
||||
perror("File open failed: exiting!");
|
||||
exit(0);
|
||||
}
|
||||
for(t=0;t<5;t++){
|
||||
long long step=t;
|
||||
printf("Writing timestep %u\n",t);
|
||||
for(i=0;i<sz;i++) {
|
||||
x[i]=(double)(i+t);
|
||||
y[i]=0.1 + (double)(i+t);
|
||||
z[i]=0.2 + (double)(i+t);
|
||||
id[i]=i;
|
||||
}
|
||||
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);
|
||||
H5PartWriteStepAttrib(file,"Step",H5T_NATIVE_INT64,&step,1);
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
printf("OK, close file and reopen for reading\n");
|
||||
file= H5PartOpenFile("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;i<nds;i++){ /* and print out those names */
|
||||
H5PartGetDatasetName(file,i,name,64);
|
||||
printf("\tDataset[%u] name=[%s]\n",
|
||||
i,name);
|
||||
}
|
||||
puts("===============================\n\n");
|
||||
|
||||
nfattribs=H5PartGetNumFileAttribs(file);
|
||||
printf("Number of datasteps in file is %u num file attribs=%d\n",
|
||||
nt,nfattribs);
|
||||
for(t=0;t<nt;t++){
|
||||
int nparticles;
|
||||
H5PartSetStep(file,t); /* select a timestep */
|
||||
nparticles=(int)H5PartGetNumParticles(file);
|
||||
nsattribs=H5PartGetNumStepAttribs(file);
|
||||
printf("Step[%u] nparticles this step=%u stepattribs=%u\n",
|
||||
t,nparticles,nsattribs); /* get num particles this step */
|
||||
if(nsattribs>0){
|
||||
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,x,y,z,id);
|
||||
printf("\tid\t\tx\t\ty\t\tz\n");
|
||||
puts("\t----------------------------------------------------");
|
||||
for(i=0;i<sz;i++) {
|
||||
printf("\t%llu\t%f\t%f\t%f\n\n",id[i],x[i],y[i],z[i]);
|
||||
}
|
||||
}
|
||||
H5PartCloseFile(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef _H5Part_HH_
|
||||
#define _H5Part_HH_
|
||||
|
||||
extern "C" {
|
||||
#include "H5PartTypes.h"
|
||||
#include "H5Part.h"
|
||||
}
|
||||
|
||||
/* Add any C++ specific extensions/implementations/wrappers here */
|
||||
|
||||
#endif
|
||||
-303
@@ -1,303 +0,0 @@
|
||||
#ifndef _H5UNITS_H_
|
||||
#define _H5UNITS_H_
|
||||
/*!
|
||||
Defines Units and conversion factors
|
||||
|
||||
\note Derived from GEANT 4 header files G4SIunits.hh
|
||||
|
||||
The basic units are those of the International System:
|
||||
|
||||
meter
|
||||
second
|
||||
kilogram
|
||||
ampere
|
||||
degree kelvin
|
||||
the amount of substance (mole)
|
||||
luminous intensity (candela)
|
||||
radian
|
||||
steradian
|
||||
|
||||
We also define some accelerator specific units
|
||||
|
||||
MeV
|
||||
beta
|
||||
|
||||
Idea of usage: For each attribute (for example x) we have two additional
|
||||
informations, namely the attributes unit and the attributes conversion factor,
|
||||
which is the factor to convert the attributes unit into SI units.
|
||||
|
||||
Example:
|
||||
|
||||
We have a lenght attribute x and the values in x are stored in mm we then would
|
||||
have to add the following information to the attribute x: METER, 1000
|
||||
|
||||
Using the following prototypes
|
||||
|
||||
H5PartWriteUnit (H5PartFile *f, char *name, const int unit );
|
||||
H5PartWriteUnitConversionFac (H5PartFile *f, char *name, const double fac);
|
||||
|
||||
one would write
|
||||
|
||||
H5PartWriteUnit (fp,"x", METER );
|
||||
H5PartWriteUnitConversionFac (fp, "x", 1000);
|
||||
|
||||
Note: in case of BETA and GAMMA one has the know the particles mass
|
||||
not sure if that is the best solution
|
||||
|
||||
Author: Andreas Adelmann (PSI)
|
||||
Date: 15.8.2006
|
||||
|
||||
*/
|
||||
|
||||
// Define SI units
|
||||
// \note enum type would be much better, have to check f77 implications
|
||||
|
||||
#define METER 1
|
||||
#define SECOND 2
|
||||
#define KILOGRAM 3
|
||||
#define AMPERE 4
|
||||
#define DEGREE_KELVIN 5
|
||||
#define MOLE 6
|
||||
#define CANDELA 7
|
||||
#define RADIAN 8
|
||||
#define STERADIAN 9
|
||||
|
||||
// Define some accelerator specific units
|
||||
|
||||
#define MEV 10
|
||||
#define BETA 11
|
||||
#define GAMMA 12
|
||||
|
||||
//
|
||||
// Length [L]
|
||||
//
|
||||
static const double meter = 1.;
|
||||
static const double meter2 = meter*meter;
|
||||
static const double meter3 = meter*meter*meter;
|
||||
|
||||
static const double millimeter = 0.001*meter;
|
||||
static const double millimeter2 = millimeter*millimeter;
|
||||
static const double millimeter3 = millimeter*millimeter*millimeter;
|
||||
|
||||
static const double centimeter = 10.*millimeter;
|
||||
static const double centimeter2 = centimeter*centimeter;
|
||||
static const double centimeter3 = centimeter*centimeter*centimeter;
|
||||
|
||||
static const double kilometer = 1000.*meter;
|
||||
static const double kilometer2 = kilometer*kilometer;
|
||||
static const double kilometer3 = kilometer*kilometer*kilometer;
|
||||
|
||||
static const double parsec = 3.0856775807e+16*meter;
|
||||
|
||||
static const double micrometer = 1.e-6 *meter;
|
||||
static const double nanometer = 1.e-9 *meter;
|
||||
static const double angstrom = 1.e-10*meter;
|
||||
static const double fermi = 1.e-15*meter;
|
||||
|
||||
static const double barn = 1.e-28*meter2;
|
||||
static const double millibarn = 1.e-3 *barn;
|
||||
static const double microbarn = 1.e-6 *barn;
|
||||
static const double nanobarn = 1.e-9 *barn;
|
||||
static const double picobarn = 1.e-12*barn;
|
||||
|
||||
// symbols
|
||||
static const double mm = millimeter;
|
||||
static const double mm2 = millimeter2;
|
||||
static const double mm3 = millimeter3;
|
||||
|
||||
static const double cm = centimeter;
|
||||
static const double cm2 = centimeter2;
|
||||
static const double cm3 = centimeter3;
|
||||
|
||||
static const double m = meter;
|
||||
static const double m2 = meter2;
|
||||
static const double m3 = meter3;
|
||||
|
||||
static const double km = kilometer;
|
||||
static const double km2 = kilometer2;
|
||||
static const double km3 = kilometer3;
|
||||
|
||||
static const double pc = parsec;
|
||||
|
||||
//
|
||||
// Angle
|
||||
//
|
||||
static const double radian = 1.;
|
||||
static const double milliradian = 1.e-3*radian;
|
||||
static const double degree = (3.14159265358979323846/180.0)*radian;
|
||||
|
||||
static const double steradian = 1.;
|
||||
|
||||
// symbols
|
||||
static const double rad = radian;
|
||||
static const double mrad = milliradian;
|
||||
static const double sr = steradian;
|
||||
static const double deg = degree;
|
||||
|
||||
//
|
||||
// Time [T]
|
||||
//
|
||||
static const double second = 1.;
|
||||
static const double nanosecond = 1.e-9 *second;
|
||||
static const double millisecond = 1.e-3 *second;
|
||||
static const double microsecond = 1.e-6 *second;
|
||||
static const double picosecond = 1.e-12*second;
|
||||
|
||||
static const double hertz = 1./second;
|
||||
static const double kilohertz = 1.e+3*hertz;
|
||||
static const double megahertz = 1.e+6*hertz;
|
||||
|
||||
// symbols
|
||||
static const double ns = nanosecond;
|
||||
static const double s = second;
|
||||
static const double ms = millisecond;
|
||||
|
||||
//
|
||||
// Mass [E][T^2][L^-2]
|
||||
//
|
||||
static const double kilogram = 1.;
|
||||
static const double gram = 1.e-3*kilogram;
|
||||
static const double milligram = 1.e-3*gram;
|
||||
|
||||
// symbols
|
||||
static const double kg = kilogram;
|
||||
static const double g = gram;
|
||||
static const double mg = milligram;
|
||||
|
||||
//
|
||||
// Electric current [Q][T^-1]
|
||||
//
|
||||
static const double ampere = 1.;
|
||||
static const double milliampere = 1.e-3*ampere;
|
||||
static const double microampere = 1.e-6*ampere;
|
||||
static const double nanoampere = 1.e-9*ampere;
|
||||
|
||||
//
|
||||
// Electric charge [Q]
|
||||
//
|
||||
static const double coulomb = ampere*second;
|
||||
static const double e_SI = 1.60217733e-19; // positron charge in coulomb
|
||||
static const double eplus = e_SI*coulomb ; // positron charge
|
||||
|
||||
//
|
||||
// Energy [E]
|
||||
//
|
||||
static const double joule = kg*m*m/(s*s);
|
||||
|
||||
static const double electronvolt = e_SI*joule;
|
||||
static const double kiloelectronvolt = 1.e+3*electronvolt;
|
||||
static const double megaelectronvolt = 1.e+6*electronvolt;
|
||||
static const double gigaelectronvolt = 1.e+9*electronvolt;
|
||||
static const double teraelectronvolt = 1.e+12*electronvolt;
|
||||
static const double petaelectronvolt = 1.e+15*electronvolt;
|
||||
|
||||
// symbols
|
||||
static const double MeV = megaelectronvolt;
|
||||
static const double eV = electronvolt;
|
||||
static const double keV = kiloelectronvolt;
|
||||
static const double GeV = gigaelectronvolt;
|
||||
static const double TeV = teraelectronvolt;
|
||||
static const double PeV = petaelectronvolt;
|
||||
|
||||
//
|
||||
// Power [E][T^-1]
|
||||
//
|
||||
static const double watt = joule/second; // watt = 6.24150 e+3 * MeV/ns
|
||||
|
||||
//
|
||||
// Force [E][L^-1]
|
||||
//
|
||||
static const double newton = joule/meter; // newton = 6.24150 e+9 * MeV/mm
|
||||
|
||||
//
|
||||
// Pressure [E][L^-3]
|
||||
//
|
||||
#define pascal hep_pascal // a trick to avoid warnings
|
||||
static const double hep_pascal = newton/m2; // pascal = 6.24150 e+3 * MeV/mm3
|
||||
static const double bar = 100000*pascal; // bar = 6.24150 e+8 * MeV/mm3
|
||||
static const double atmosphere = 101325*pascal; // atm = 6.32420 e+8 * MeV/mm3
|
||||
|
||||
//
|
||||
// Electric potential [E][Q^-1]
|
||||
//
|
||||
static const double megavolt = megaelectronvolt/eplus;
|
||||
static const double kilovolt = 1.e-3*megavolt;
|
||||
static const double volt = 1.e-6*megavolt;
|
||||
|
||||
//
|
||||
// Electric resistance [E][T][Q^-2]
|
||||
//
|
||||
static const double ohm = volt/ampere; // ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns)
|
||||
|
||||
//
|
||||
// Electric capacitance [Q^2][E^-1]
|
||||
//
|
||||
static const double farad = coulomb/volt; // farad = 6.24150e+24 * eplus/Megavolt
|
||||
static const double millifarad = 1.e-3*farad;
|
||||
static const double microfarad = 1.e-6*farad;
|
||||
static const double nanofarad = 1.e-9*farad;
|
||||
static const double picofarad = 1.e-12*farad;
|
||||
|
||||
//
|
||||
// Magnetic Flux [T][E][Q^-1]
|
||||
//
|
||||
static const double weber = volt*second; // weber = 1000*megavolt*ns
|
||||
|
||||
//
|
||||
// Magnetic Field [T][E][Q^-1][L^-2]
|
||||
//
|
||||
static const double tesla = volt*second/meter2; // tesla =0.001*megavolt*ns/mm2
|
||||
|
||||
static const double gauss = 1.e-4*tesla;
|
||||
static const double kilogauss = 1.e-1*tesla;
|
||||
|
||||
//
|
||||
// Inductance [T^2][E][Q^-2]
|
||||
//
|
||||
static const double henry = weber/ampere; // henry = 1.60217e-7*MeV*(ns/eplus)**2
|
||||
|
||||
//
|
||||
// Temperature
|
||||
//
|
||||
static const double kelvin = 1.;
|
||||
|
||||
//
|
||||
// Amount of substance
|
||||
//
|
||||
static const double mole = 1.;
|
||||
|
||||
//
|
||||
// Activity [T^-1]
|
||||
//
|
||||
static const double becquerel = 1./second ;
|
||||
static const double curie = 3.7e+10 * becquerel;
|
||||
|
||||
//
|
||||
// Absorbed dose [L^2][T^-2]
|
||||
//
|
||||
static const double gray = joule/kilogram ;
|
||||
|
||||
//
|
||||
// Luminous intensity [I]
|
||||
//
|
||||
static const double candela = 1.;
|
||||
|
||||
//
|
||||
// Luminous flux [I]
|
||||
//
|
||||
static const double lumen = candela*steradian;
|
||||
|
||||
//
|
||||
// Illuminance [I][L^-2]
|
||||
//
|
||||
static const double lux = lumen/meter2;
|
||||
|
||||
//
|
||||
// Miscellaneous
|
||||
//
|
||||
static const double perCent = 0.01 ;
|
||||
static const double perThousand = 0.001;
|
||||
static const double perMillion = 0.000001;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
/*! \mainpage
|
||||
<H1>H5Part: a Portable High Performance Parallel Data Interface to HDF5
|
||||
</H1>
|
||||
<P>
|
||||
<B>
|
||||
Particle based simulations of accelerator beam-lines, especially in six dimensional phase space, generate vast amounts of data.
|
||||
Even though a subset of statistical information regarding phase space or analysis needs to be preserved, reading and writing such enormous restart
|
||||
files on massively parallel supercomputing systems remains challenging.
|
||||
<P>
|
||||
H5Part consists of Particles, Block structured Fields and unstructured data (Topo). <P>
|
||||
Developed by .
|
||||
</B>
|
||||
<P>
|
||||
For further information contact: <a href="mailto:xxxxx">xxxxxx</a> -
|
||||
xxxx xxxxx, (xxx) xxx.
|
||||
<P>
|
||||
Last modified on xxx xx, 2006.
|
||||
<p>
|
||||
Papers:
|
||||
<P>
|
||||
<a href="http://www-vis.lbl.gov/Research/AcceleratorSAPP/index.html">LBNL Vis Group </a><br>
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
#ifdef GTHDF5
|
||||
template<class T,unsigned int Dim> void DataSink<T,Dim>::savePhaseSpaceData()
|
||||
{
|
||||
T *x=(double*)malloc(beam_m->getLocalNum()*sizeof(double));
|
||||
T *y=(double*)malloc(beam_m->getLocalNum()*sizeof(double));
|
||||
T *z=(double*)malloc(beam_m->getLocalNum()*sizeof(double));
|
||||
T *px=(double*)malloc(beam_m->getLocalNum()*sizeof(double));
|
||||
T *py=(double*)malloc(beam_m->getLocalNum()*sizeof(double));
|
||||
T *pz=(double*)malloc(beam_m->getLocalNum()*sizeof(double));
|
||||
h5part_int64_t int *id=(h5part_int64_t int*)malloc(beam_m->getLocalNum()*sizeof(h5part_int64_t));
|
||||
|
||||
double actPos = beam_m->getActSPos();
|
||||
double structLenght = beam_m->getMaxZ();
|
||||
Vector_t org = beam_m->getOrigin();
|
||||
Vector_t maxX = beam_m->getRmax();
|
||||
Vector_t minX = beam_m->getRmin();
|
||||
Vector_t maxP = beam_m->getPmax();
|
||||
Vector_t minP = beam_m->getPmin();
|
||||
unsigned long protons = beam_m->getNumberOfProtons();
|
||||
unsigned long electrons = beam_m->getNumberOfElectrons();
|
||||
Vector_t centroid = beam_m->getCentroid();
|
||||
unsigned nTot = beam_m->getTotalNum();
|
||||
for (h5part_int64_t i=0; i<beam_m->getLocalNum();i++) {
|
||||
x[i] = beam_m->R[i](0);
|
||||
y[i] = beam_m->R[i](1);
|
||||
z[i] = beam_m->R[i](2);
|
||||
px[i] = beam_m->P[i](0);
|
||||
py[i] = beam_m->P[i](1);
|
||||
pz[i] = beam_m->P[i](2);
|
||||
if (i< (electrons-1))
|
||||
id[i] = beam_m->ID[i]; else
|
||||
id[i] = -1*(long int)beam_m->ID[i];
|
||||
}
|
||||
H5PartSetStep(file_m,idx_m); /* must set the current timestep in file */
|
||||
H5PartSetNumParticles(file_m,beam_m->getLocalNum()); /* then set number of particles to store */
|
||||
/* now write different tuples of data into this timestep of the file */
|
||||
H5PartWriteDataFloat64(file_m,"x",x);
|
||||
H5PartWriteDataFloat64(file_m,"y",y);
|
||||
H5PartWriteDataFloat64(file_m,"z",z);
|
||||
H5PartWriteDataFloat64(file_m,"px",px);
|
||||
H5PartWriteDataFloat64(file_m,"py",py);
|
||||
H5PartWriteDataFloat64(file_m,"pz",pz);
|
||||
H5PartWriteDataInt64(file_m,"id",id);
|
||||
h5part_int64_t step = idx_m;
|
||||
H5PartWriteStepAttrib(file_m,"Step",H5T_NATIVE_INT64,&step,1);
|
||||
|
||||
|
||||
/* write scalar data i.e the header */
|
||||
H5PartWriteAttrib(file_m,"Spos",H5T_NATIVE_DOUBLE,&actPos,1);
|
||||
H5PartWriteAttrib(file_m,"structLen",H5T_NATIVE_DOUBLE,&structLenght,1);
|
||||
|
||||
H5PartWriteAttrib(file_m,"org",H5T_NATIVE_DOUBLE,&org,3);
|
||||
H5PartWriteAttrib(file_m,"maxX",H5T_NATIVE_DOUBLE,&maxX,3);
|
||||
H5PartWriteAttrib(file_m,"minX",H5T_NATIVE_DOUBLE,&minX,3);
|
||||
H5PartWriteAttrib(file_m,"maxP",H5T_NATIVE_DOUBLE,&maxP,3);
|
||||
H5PartWriteAttrib(file_m,"minP",H5T_NATIVE_DOUBLE,&minP,3);
|
||||
H5PartWriteAttrib(file_m,"centroid",H5T_NATIVE_DOUBLE,¢roid,3);
|
||||
delete x;
|
||||
delete y;
|
||||
delete z;
|
||||
delete id;
|
||||
idx_m++;
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import string, sys
|
||||
sys.path.append('../src/')
|
||||
import H5Part
|
||||
from optparse import OptionParser
|
||||
|
||||
|
||||
parser = OptionParser()
|
||||
|
||||
print_all=0
|
||||
|
||||
parser.add_option("-1", "--1var", dest="var_1",
|
||||
help="(REQUIRED) Takes first variable parameter")
|
||||
|
||||
parser.add_option("-2", "--2var", dest="var_2",
|
||||
help="(REQUIRED) Takes second variable parameter")
|
||||
|
||||
parser.add_option("-i", "--input", dest="input_file",
|
||||
help="(REQUIRED) Takes input file name")
|
||||
|
||||
parser.add_option("-t", "--timestep", dest="timestep", type="int",
|
||||
help="(REQUIRED) Sets the timestep (Value -1 will result in dumping values of all timesteps.)")
|
||||
|
||||
parser.add_option("-o", "--output", dest="output_file",
|
||||
help="(OPTIONAL) Takes output file name (without this flag, the program will print to stdout)")
|
||||
|
||||
parser.add_option("-n", "--number", dest="nparticle", type="int",
|
||||
help="(OPTIONAL) Sets number of output points")
|
||||
|
||||
parser.add_option("-s", "--start", dest="start", type="int",
|
||||
help="(OPTIONAL) Sets the starting particle index")
|
||||
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.timestep == -1:
|
||||
print_all = 1
|
||||
|
||||
MAX_LEN = 100
|
||||
stop = 0
|
||||
start_indx = 0
|
||||
|
||||
h5file = H5Part.H5PartOpenFile(options.input_file, H5Part.H5PART_READ)
|
||||
|
||||
if H5Part.H5PartFileIsValid(h5file)==0 :
|
||||
print "unable to open input file"
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
j = options.timestep
|
||||
ntime_step = j+1
|
||||
|
||||
if print_all == 1:
|
||||
j=0
|
||||
ntime_step = H5Part.H5PartGetNumSteps(h5file)
|
||||
|
||||
for j in range(j, ntime_step):
|
||||
H5Part.H5PartSetStep(h5file,j)
|
||||
num_dataset = H5Part.H5PartGetNumDatasets(h5file)
|
||||
for i in range(0, num_dataset):
|
||||
data_name, data_type, nparticle = H5Part.H5PartGetDatasetInfo(h5file, i, MAX_LEN)
|
||||
if data_name == options.var_1:
|
||||
type_1=data_type
|
||||
if data_name == options.var_2:
|
||||
type_2=data_type
|
||||
# # # # # # # # # # # # # # # # I MUST FIND A WAY... hid_t & H5T_NATIVE_INT64 etc undefined problem... Currently treated as int...
|
||||
|
||||
#temp = H5Part.hid_tArray(2)
|
||||
#temp[0] = H5T_NATIVE_INT64
|
||||
#print temp[0]
|
||||
|
||||
if type_1 == 201326626: # H5Part.H5T_NATIVE_INT64:
|
||||
value_1 = H5Part.longArray(nparticle)
|
||||
H5Part.H5PartReadDataInt64(h5file, options.var_1, value_1)
|
||||
elif type_1 == 201326635: # H5Part.H5T_NATIVE_DOUBLE:
|
||||
value_1 = H5Part.doubleArray(nparticle)
|
||||
H5Part.H5PartReadDataFloat64(h5file, options.var_1, value_1)
|
||||
else:
|
||||
print "Dataset Type is UNKNOWN for %s. (Check the variable name.)\n" % options.var_1
|
||||
sys.exit(1)
|
||||
|
||||
if type_2 == 201326626: # H5Part.H5T_NATIVE_INT64:
|
||||
value_2 = H5Part.longArray(nparticle)
|
||||
H5Part.H5PartReadDataInt64(h5file, options.var_2, value_2)
|
||||
elif type_2 == 201326635: # H5Part.H5T_NATIVE_DOUBLE:
|
||||
value_2 = H5Part.doubleArray(nparticle)
|
||||
H5Part.H5PartReadDataFloat64(h5file, options.var_2, value_2)
|
||||
else:
|
||||
print "Dataset Type is UNKNOWN for %s. (Check the variable name.)\n" % options.var_2
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if options.start != None:
|
||||
start_indx = options.start
|
||||
|
||||
if options.nparticle != None:
|
||||
stop = options.nparticle + start_indx
|
||||
else:
|
||||
stop = nparticle
|
||||
|
||||
if stop > nparticle:
|
||||
stop = nparticle
|
||||
|
||||
if options.output_file != None:
|
||||
outFile = open(options.output_file,"w")
|
||||
|
||||
for x in range(start_indx, stop):
|
||||
if type_1 == 201326626: # H5Part.H5T_NATIVE_INT64:
|
||||
outFile.write("%ld" % value_1[x])
|
||||
elif type_1 == 201326635: # H5Part.H5T_NATIVE_DOUBLE:
|
||||
outFile.write("%lf" % value_1[x])
|
||||
|
||||
if type_2 == 201326626: # H5Part.H5T_NATIVE_INT64:
|
||||
outFile.write("\t%ld" % value_2[x])
|
||||
outFile.write("\n")
|
||||
elif type_2 == 201326635: # H5Part.H5T_NATIVE_DOUBLE:
|
||||
outFile.write("\t%lf" % value_2[x])
|
||||
outFile.write("\n")
|
||||
|
||||
outFile.write("\n")
|
||||
outFile.close()
|
||||
|
||||
else:
|
||||
for y in range(start_indx, stop):
|
||||
if type_1 == 201326626: # H5Part.H5T_NATIVE_INT64:
|
||||
print "%ld" % value_1[y],
|
||||
elif type_1 == 201326635: # H5Part.H5T_NATIVE_DOUBLE:
|
||||
print "%lf" % value_1[y],
|
||||
|
||||
if type_2 == 201326626: # H5Part.H5T_NATIVE_INT64:
|
||||
print "\t%ld" % value_2[y]
|
||||
elif type_2 == 201326635: # H5Part.H5T_NATIVE_DOUBLE:
|
||||
print "\t%lf" % value_2[y]
|
||||
|
||||
print "\n"
|
||||
|
||||
|
||||
H5Part.H5PartCloseFile(h5file)
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# print "I'M RUNNING AS A MAIN PROGRAM!!!"
|
||||
Reference in New Issue
Block a user