Commit e037f5f2 authored by gsell's avatar gsell

close H5hut property list after opening a file

parent 45834ab5
\newcommand{\opalversion}[1]{Version \ifstrempty{#1}{1.9.0}{#1}\xspace}
......@@ -27,7 +27,8 @@ void H5Reader::open(int step) {
assert (h5err != H5_ERR);
file_m = H5OpenFile (filename_m.c_str(), H5_O_RDONLY, props);
assert (file_m != (h5_file_t)H5_ERR);
H5CloseProp (props);
H5SetStep(file_m, step);
}
......@@ -140,7 +141,8 @@ void H5Reader::writeScalarField(const container_t& scalfield,
assert (h5err != H5_ERR);
file = H5OpenFile (fname.c_str(), H5_O_WRONLY, props);
assert (file != (h5_file_t)H5_ERR);
H5CloseProp (props);
H5SetStep (file, 0);
h5_int64_t herr;
......
......@@ -479,6 +479,7 @@ public:
assert (h5err != H5_ERR);
H5f_m = H5OpenFile (fn.c_str(), H5_O_RDONLY, props);
assert (H5f_m != (h5_file_t)H5_ERR);
H5CloseProp (props);
}
......
......@@ -31,6 +31,7 @@ FM3DH5Block::FM3DH5Block(std::string aFilename):Fieldmap(aFilename) {
assert (h5err != H5_ERR);
h5_file_t file = H5OpenFile (aFilename.c_str(), H5_O_RDONLY, props);
assert (file != (h5_file_t)H5_ERR);
H5CloseProp (props);
h5_int64_t last_step = H5GetNumSteps(file) - 1;
assert (last_step >= 0);
......@@ -88,6 +89,7 @@ void FM3DH5Block::readMap() {
assert (h5err != H5_ERR);
h5_file_t file = H5OpenFile (Filename_m.c_str(), H5_O_RDONLY, props);
assert (file != (h5_file_t)H5_ERR);
H5CloseProp (props);
long field_size = 0;
int Nnodes = Ippl::getNodes();
......
......@@ -31,6 +31,7 @@ FM3DH5Block_nonscale::FM3DH5Block_nonscale(std::string aFilename):
assert (h5err != H5_ERR);
h5_file_t file = H5OpenFile (aFilename.c_str(), H5_O_RDONLY, props);
assert (file != (h5_file_t)H5_ERR);
H5CloseProp (props);
h5_int64_t last_step = H5GetNumSteps(file) - 1;
assert (last_step >= 0);
......@@ -92,6 +93,7 @@ void FM3DH5Block_nonscale::readMap() {
assert (h5err != H5_ERR);
h5_file_t file = H5OpenFile (Filename_m.c_str(), H5_O_RDONLY, props);
assert (file != (h5_file_t)H5_ERR);
H5CloseProp (props);
long field_size = 0;
int Nnodes = Ippl::getNodes();//min(20, Ippl::getNodes());
......
......@@ -31,6 +31,7 @@ FM3DMagnetoStaticH5Block::FM3DMagnetoStaticH5Block(string aFilename):
assert (h5err != H5_ERR);
h5_file_t file = H5OpenFile (aFilename.c_str(), H5_O_RDONLY, props);
assert (file != (h5_file_t)H5_ERR);
H5CloseProp (props);
h5_int64_t last_step = H5GetNumSteps(file) - 1;
assert (last_step >= 0);
......@@ -95,6 +96,7 @@ void FM3DMagnetoStaticH5Block::readMap() {
assert (h5err != H5_ERR);
h5_file_t file = H5OpenFile (Filename_m.c_str(), H5_O_RDONLY, props);
assert (file != (h5_file_t)H5_ERR);
H5CloseProp (props);
long field_size = 0;
int Nnodes = Ippl::getNodes();//min(20, Ippl::getNodes());
......
......@@ -366,7 +366,8 @@ MapType Fieldmap::readHeader(std::string Filename) {
assert (h5err != H5_ERR);
h5_file_t file = H5OpenFile (Filename.c_str(), H5_O_RDONLY, props);
assert (file != (h5_file_t)H5_ERR);
H5CloseProp (props);
h5err = H5SetStep(file, 0);
assert (h5err != H5_ERR);
......
......@@ -85,6 +85,7 @@ void LossDataSink::openH5(h5_int32_t mode) {
throw GeneralClassicException("LossDataSink::openH5",
"failed to open h5 file '" + fn_m + "'");
}
H5CloseProp (props);
}
void LossDataSink::writeHeaderH5() {
......
......@@ -1734,6 +1734,7 @@ Change orientation if diff is:
MPI_Comm comm = Ippl::getComm();
H5SetPropFileMPIOCollective (props, &comm);
h5_file_t f = H5OpenFile (h5FileName_m.c_str(), H5_O_RDONLY, props);
H5CloseProp (props);
h5t_mesh_t* m = NULL;
H5FedOpenTriangleMesh (f, "0", &m);
......
......@@ -1013,6 +1013,7 @@ void DataSink::writeSurfaceInteraction(PartBunchBase<double, 3> *beam, long long
throw OpalException("DataSink::writeSurfaceInteraction",
"failed to open h5 file '" + surfaceLossFileName_m + "' for surface loss");
}
H5CloseProp (props);
}
int nTot = bg.getNumBFaces();
......@@ -1514,4 +1515,4 @@ void DataSink::writeMemoryData(PartBunchBase<double, 3> *beam,
/***************************************************************************
* $RCSfile: DataSink.cpp,v $ $Author: adelmann $
* $Revision: 1.3 $ $Date: 2004/06/02 19:38:54 $
***************************************************************************/
\ No newline at end of file
***************************************************************************/
......@@ -77,6 +77,7 @@ void H5PartWrapper::open(h5_int32_t flags) {
assert (h5err != H5_ERR);
file_m = H5OpenFile (fileName_m.c_str(), flags, props);
assert (file_m != (h5_file_t)H5_ERR);
H5CloseProp (props);
}
void H5PartWrapper::storeCavityInformation() {
......@@ -131,6 +132,7 @@ void H5PartWrapper::copyFile(const std::string &sourceFile, int lastStep, h5_int
assert (h5err != H5_ERR);
h5_file_t source = H5OpenFile (sourceFile.c_str(), H5_O_RDONLY, props);
assert (source != (h5_file_t)H5_ERR);
H5CloseProp (props);
h5_ssize_t numStepsInSource = H5GetNumSteps(source);
if (lastStep == -1 || lastStep >= numStepsInSource) {
......@@ -164,6 +166,7 @@ void H5PartWrapper::copyFile(const std::string &sourceFile, int lastStep, h5_int
assert (h5err != H5_ERR);
source = H5OpenFile (sourceFileName.c_str(), H5_O_RDONLY, props);
assert (source != (h5_file_t)H5_ERR);
H5CloseProp (props);
copyHeader(source);
if (lastStep < 0) {
......@@ -198,6 +201,7 @@ void H5PartWrapper::copyFile(const std::string &sourceFile, int lastStep, h5_int
assert (h5err != H5_ERR);
h5_file_t source = H5OpenFile (sourceFile.c_str(), H5_O_RDONLY, props);
assert (source != (h5_file_t)H5_ERR);
H5CloseProp (props);
h5_ssize_t numStepsInSource = H5GetNumSteps(source);
if (lastStep == -1 || lastStep >= numStepsInSource) {
......@@ -522,4 +526,4 @@ size_t H5PartWrapper::getNumParticles() const {
// mode:c++
// c-basic-offset: 4
// indent-tabs-mode:nil
// End:
\ No newline at end of file
// End:
......@@ -112,6 +112,7 @@ void readH5HutFile(const std::string &fname, size_t step, data_t &data, attribut
H5SetPropFileMPIOCollective (props, &comm);
file_t file = H5OpenFile(fname.c_str(), H5_O_RDONLY, props);
H5CloseProp (props);
h5_ssize_t numStepsInSource = H5GetNumSteps(file);
h5_ssize_t readStep = (step > (size_t)(numStepsInSource - 1)? numStepsInSource - 1: step);
......@@ -336,6 +337,7 @@ void printInfo(const std::string &input) {
H5SetPropFileMPIOCollective (props, &comm);
file_t file = H5OpenFile(input.c_str(), H5_O_RDONLY, props);
H5CloseProp (props);
h5_ssize_t numStepsInSource = H5GetNumSteps(file);
std::cout << std::left << std::setw(15) << "Step number" << std::setw(15) << "Position [m]" << std::endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment