From 7a7a90b5df7a5ea657196d1c81a960826cdedfba Mon Sep 17 00:00:00 2001 From: Andreas Adelmann Date: Mon, 13 Nov 2006 20:00:07 +0000 Subject: [PATCH] Initial update --- .gitattributes | 1 + tools/homdynToH5p.cc | 90 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 tools/homdynToH5p.cc diff --git a/.gitattributes b/.gitattributes index db782e4..d68fae8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -80,6 +80,7 @@ tools/Makefile.am -text tools/README -text tools/h5pAttrib.cc -text tools/h5pToGNUplot.cc -text +tools/homdynToH5p.cc -text visit_plugins/databases/H5Part/.depend -text visit_plugins/databases/H5Part/Makefile -text visit_plugins/databases/H5Part/README.txt -text diff --git a/tools/homdynToH5p.cc b/tools/homdynToH5p.cc new file mode 100644 index 0000000..e2579d9 --- /dev/null +++ b/tools/homdynToH5p.cc @@ -0,0 +1,90 @@ +/* + Read Homdyn Hxxx.DAT and convert it to the H5Part data + format. + + g++ -I/Users/adelmann/install/hdf5-1.6.5/hdf5/include -I/Users/adelmann/svnwork/H5Part/src -g -c homdynToH5p.cc + g++ -o homdynToH5p homdynToH5p.o -L/Users/adelmann/svnwork/H5Part/src -lH5Part -L/Users/adelmann/install/hdf5-1.6.5/hdf5/lib -lhdf5 -lz -lm + + + Usage: homdynToH5p [-f newFilename] + + Reads HBUNCH.OUT and writes the data to HBUNCH.h5 or newFilename.h5 + + + +*/ + +#include "H5Part.h" +#include +#include +#include + +using namespace std; + +int main(int argc,char *argv[]){ + + const int nCol = 25; + const int nHeader = 1; + int nLines = 0; + + H5PartFile *file; + + double data[nCol][10000]; + string headers[nCol]; + + string fnStr("HBUNCH.OUT"); + + ifstream in; + + /* + Open and read HOMDYN File: + */ + + in.open(fnStr.c_str()); + + /* + over read possible header + */ + + for (int l=0;l> headers[c]; + cout << c << " - - " << headers[c] << endl; + } + } + headers[0] = string("SPOS"); // H5Root needs this name + /* + read in file data + */ + + while (1) { + for (int c=0;c> data[c][nLines]; + if (!in.good()) break; + nLines++; + } + + in.close(); + + cout << "In HBUNCH.OUT found " << nLines << " lines " << endl; + + file=H5PartOpenFile("HBUNCH.h5",H5PART_WRITE); + if(!file) { + perror("File open failed: exiting!"); + exit(0); + } + + H5PartWriteFileAttribString(file,"File Description", "This file contains HOMDYN HBUNCH.OUT data"); + + for (int c=0;c