Commit ad650c17 authored by gsell's avatar gsell

error checks for H5OpenFile() calls fixed

parent 1bca879d
......@@ -25,8 +25,7 @@ FM3DH5Block::FM3DH5Block(std::string aFilename):
Type = T3DDynamicH5Block;
h5_file_t *file = H5OpenFile(aFilename.c_str(), H5_O_RDONLY, Ippl::getComm());
if(file) {
if(file != (void*)H5_ERR) {
h5_int64_t last_step = H5GetNumSteps(file) - 1;
h5err = H5SetStep(file, last_step);
if(h5err != H5_SUCCESS)
......@@ -82,7 +81,7 @@ void FM3DH5Block::readMap() {
Inform msg("FM3DH5 ");
h5_file_t *file = H5OpenFile(Filename_m.c_str(), H5_O_RDONLY, Ippl::getComm());
if(file) {
if(file != (void*)H5_ERR) {
h5_int64_t h5err;
long field_size = 0;
......
......@@ -24,8 +24,7 @@ FM3DH5Block_nonescale::FM3DH5Block_nonescale(std::string aFilename):
Type = T3DDynamicH5Block;
h5_file_t *file = H5OpenFile(aFilename.c_str(), H5_O_RDONLY, Ippl::getComm());
if(file) {
if(file != (void*)H5_ERR) {
h5_int64_t last_step = H5GetNumSteps(file) - 1;
h5err = H5SetStep(file, last_step);
if(h5err != H5_SUCCESS)
......@@ -82,7 +81,7 @@ void FM3DH5Block_nonescale::readMap() {
Inform msg("FM3DH5_NS ");
h5_file_t *file = H5OpenFile(Filename_m.c_str(), H5_O_RDONLY, Ippl::getComm());
if(file) {
if(file != (void*)H5_ERR) {
h5_int64_t h5err;
long field_size = 0;
......
......@@ -24,8 +24,7 @@ FM3DMagnetoStaticH5Block::FM3DMagnetoStaticH5Block(string aFilename):
Type = T3DMagnetoStaticH5Block;
h5_file_t *file = H5OpenFile(aFilename.c_str(), H5_O_RDONLY, Ippl::getComm());
if(file) {
if(file != (void*)H5_ERR) {
h5_int64_t last_step = H5GetNumSteps(file) - 1;
h5err = H5SetStep(file, last_step);
if(h5err != H5_SUCCESS)
......@@ -79,7 +78,7 @@ void FM3DMagnetoStaticH5Block::readMap() {
Inform msg("FM3DMagH5 ");
h5_file_t *file = H5OpenFile(Filename_m.c_str(), H5_O_RDONLY, Ippl::getComm());
if(file) {
if(file != (void*)H5_ERR) {
h5_int64_t h5err;
long field_size = 0;
......
......@@ -273,7 +273,7 @@ MapType Fieldmap::readHeader(std::string Filename) {
h5_int64_t ftype;
h5_file_t *file = H5OpenFile(Filename.c_str(), H5_O_RDONLY, Ippl::getComm());
if(file) {
if(file != (void*)H5_ERR) {
h5err = H5SetStep(file, 0);
if(h5err != H5_SUCCESS)
ERRORMSG("H5 rc= " << h5err << " in " << __FILE__ << " @ line " << __LINE__ << endl);
......
......@@ -545,7 +545,7 @@ void Distribution::DoRestartOpalT(PartBunch &beam, size_t Np, int restartStep) {
H5file = H5OpenFile(fn.c_str(), H5_O_RDONLY, 0);
#endif
if(!H5file) {
if(H5file == (void*)H5_ERR) {
ERRORMSG("could not open file '" << fn << "'; exiting!" << endl);
exit(0);
}
......@@ -690,7 +690,7 @@ void Distribution::DoRestartOpalCycl(PartBunch &beam, size_t Np, int restartStep
H5file = H5OpenFile(fn.c_str(), H5_O_RDONLY, 0);
#endif
if(!H5file) {
if(H5file == (void*)H5_ERR) {
ERRORMSG("File open failed: exiting!" << endl);
exit(0);
}
......@@ -978,7 +978,7 @@ void Distribution::DoRestartOpalE(EnvelopeBunch &beam, size_t Np, int restartSte
H5file = H5PartOpenFile(fn.c_str(), H5_O_RDONLY, 0);
#endif
if(!H5file) {
if(H5file == (void*)H5_ERR) {
ERRORMSG("could not open file '" << fn << "'; exiting!" << endl);
exit(0);
}
......
......@@ -58,8 +58,8 @@ DataSink::DataSink() :
#else
H5file_m = H5OpenFile(fn.c_str(), H5_FLUSH_STEP | H5_O_WRONLY, 0);
#endif
if(!H5file_m) {
ERRORMSG("h5 file open failed: exiting!" << endl);
if (H5file_m == (void*)H5_ERR) {
ERRORMSG("h5 file " << fn.c_str() << " open failed: exiting!" << endl);
exit(0);
}
/// Write file attributes.
......@@ -125,7 +125,7 @@ DataSink::DataSink(int restartStep) :
*gmsg << "Will append to " << fn << endl;
if(!H5file_m) {
if(H5file_m == (void*)H5_ERR) {
ERRORMSG("h5 file open failed: exiting!" << endl);
exit(0);
}
......@@ -2337,7 +2337,7 @@ void DataSink::writeSurfaceInteraction(PartBunch &beam, long long &step, Boundar
H5fileS_m = H5OpenFile(surfacLossFileName_m.c_str(), H5_FLUSH_STEP | H5_O_WRONLY, 0);
#endif
if(!H5fileS_m) {
if(H5fileS_m == (void*)H5_ERR) {
ERRORMSG("h5 file for surface loss open failed: exiting!" << endl);
exit(0);
}
......@@ -2572,7 +2572,7 @@ void DataSink::storeOneBunch(const PartBunch &beam, const string fn_appendix) {
H5file = H5OpenFile(fn.c_str(), H5_FLUSH_STEP | H5_O_WRONLY, 0);
#endif
if(!H5file) {
if(H5file == (void*)H5_ERR) {
ERRORMSG("h5 file for backup bunch in OPAL-CYCL open failed: exiting!" << endl);
exit(0);
}
......@@ -2702,7 +2702,7 @@ bool DataSink::readOneBunch(PartBunch &beam, const string fn_appendix, const siz
#else
H5file = H5OpenFile(fn.c_str(), H5_O_RDONLY);
#endif
if(!H5file) {
if(H5file == (void*)H5_ERR) {
ERRORMSG("File open failed: exiting!" << endl);
exit(0);
}
......
......@@ -52,7 +52,7 @@ void LossDataSink::openH5() {
H5file_m = H5OpenFile(fn_m.c_str(), H5_O_WRONLY, 0);
#endif
if(!H5file_m) {
if(H5file_m == (void*)H5_ERR) {
ERRORMSG("h5 file open failed: exiting!" << endl);
exit(0);
}
......
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