Commit 5e031fda authored by kraus's avatar kraus
Browse files

replace all exit statements with exceptions

parent 2a60483b
......@@ -30,7 +30,7 @@
#define CHECK_CYC_FSCANF_EOF(arg) if(arg == EOF)\
throw GeneralClassicException("Cyclotron::getFieldFromFile",\
"fscanf returned EOF at " #arg);
"fscanf returned EOF at " #arg);
extern Inform *gmsg;
......@@ -789,9 +789,8 @@ void Cyclotron::getFieldFromFile(const double &scaleFactor) {
BP.Bfact = scaleFactor;
if((f = fopen(fmapfn_m.c_str(), "r")) == NULL) {
ERRORMSG("* Error in Cyclotron::getFieldFromFile()!" << endl);
ERRORMSG("* Cannot open file, please check if it really exists." << endl);
exit(1);
throw GeneralClassicException("Cyclotron::getFieldFromField",
"failed to open file '" + fmapfn_m + "', please check if it exists");
}
CHECK_CYC_FSCANF_EOF(fscanf(f, "%lf", &BP.rmin));
......@@ -1084,9 +1083,8 @@ void Cyclotron::getFieldFromFile_AVFEQ(const double &scaleFactor) {
BP.Bfact = scaleFactor / 1000.;
if((f = fopen(fmapfn_m.c_str(), "r")) == NULL) {
ERRORMSG("* Error in Cyclotron::getFieldFromFile_AVFEQ()!" << endl);
ERRORMSG("* Cannot open file, please check if it really exists." << endl);
exit(1);
throw GeneralClassicException("Cyclotron::getFieldFromFile_AVFEQ",
"failed to open file '" + fmapfn_m + "', please check if it exists");
}
CHECK_CYC_FSCANF_EOF(fscanf(f, "%lf", &BP.rmin));
......@@ -1165,9 +1163,8 @@ void Cyclotron::getFieldFromFile_Carbon(const double &scaleFactor) {
BP.Bfact = scaleFactor;
if((f = fopen(fmapfn_m.c_str(), "r")) == NULL) {
ERRORMSG("* Error in Cyclotron::getFieldFromFile_Carbon()!" << endl);
ERRORMSG("* Cannot open file, please check if it really exists." << endl);
exit(1);
throw GeneralClassicException("Cyclotron::getFieldFromFile_Carbon",
"failed to open file '" + fmapfn_m + "', please check if it exists");
}
CHECK_CYC_FSCANF_EOF(fscanf(f, "%lf", &BP.rmin));
......@@ -1259,9 +1256,8 @@ void Cyclotron::getFieldFromFile_CYCIAE(const double &scaleFactor) {
BP.Bfact = scaleFactor;
if((f = fopen(fmapfn_m.c_str(), "r")) == NULL) {
ERRORMSG("* Error in Cyclotron::getFieldFromFile_Carbon()!" << endl);
ERRORMSG(" Cannot open file, please check if it really exists." << endl);
exit(1);
throw GeneralClassicException("Cyclotron::getFieldFromFile_CYCIAE",
"failed to open file '" + fmapfn_m + "', please check if it exists");
}
CHECK_CYC_FSCANF_EOF(fscanf(f, "%lf", &BP.rmin));
......@@ -1336,9 +1332,8 @@ void Cyclotron::getFieldFromFile_BandRF(const double &scaleFactor) {
for(; fm != RFfilename_m.end(); ++fm, ++rffi, ++rfphii, ++escali, ++fcount) {
Fieldmap *f = Fieldmap::getFieldmap(*fm, false);
if(f == NULL) {
ERRORMSG("* Error in Cyclotron::getFieldFromFile_BandRF()!" << endl);
ERRORMSG(" Cannot open file, please check if it really exists." << endl);
exit(1);
throw GeneralClassicException("Cyclotron::getFieldFromFile_BandRF",
"failed to open file '" + *fm + "', please check if it exists");
}
f->readMap();
// if (IPPL::Comm->getOutputLevel() != 0)
......@@ -1352,4 +1347,4 @@ void Cyclotron::getFieldFromFile_BandRF(const double &scaleFactor) {
void Cyclotron::getDimensions(double &zBegin, double &zEnd) const
{ }
#undef CHECK_CYC_FSCANF_EOF
#undef CHECK_CYC_FSCANF_EOF
\ No newline at end of file
......@@ -22,6 +22,7 @@
#include "AbsBeamline/BeamlineVisitor.h"
#include "Algorithms/PartBunch.h"
#include "Fields/Fieldmap.hh"
#include "Utilities/GeneralClassicException.h"
#include "gsl/gsl_interp.h"
#include "gsl/gsl_spline.h"
......@@ -352,7 +353,7 @@ bool RFCavity::apply(const size_t &i, const double &t, double E[], double B[]) {
bool RFCavity::apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) {
bool out_of_bounds = true;
const Vector_t tmpR(RefPartBunch_m->getX(i) - dx_m, RefPartBunch_m->getY(i) - dy_m , RefPartBunch_m->getZ(i) - startField_m - ds_m);
if (tmpR(2) >= 0.0) {
// inside the cavity
for(size_t j = 0; j < numFieldmaps(); ++ j) {
......@@ -372,7 +373,7 @@ bool RFCavity::apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B)
}
}
else {
/*
/*
some of the bunch is still outside of the cavity
so let them drift in
*/
......@@ -524,9 +525,8 @@ void RFCavity::initialise(PartBunch *bunch, const double &scaleFactor) {
ifstream in(filename_m.c_str());
if(!in.good()) {
ERRORMSG("Error in Cyclotron::readFieldMap() !" << endl);
ERRORMSG(" Cannot open file " << filename_m << ", please check if it really exists." << endl);
exit(1);
throw GeneralClassicException("RFCavity::initialise",
"failed to open file '" + filename_m + "', please check if it exists");
}
*gmsg << "* Read cavity voltage profile data" << endl;
// << " (data format: s/L, v, dV/dr)" << endl;
......@@ -543,9 +543,8 @@ void RFCavity::initialise(PartBunch *bunch, const double &scaleFactor) {
for(int i = 0; i < num_points_m; i++) {
if(in.eof()) {
ERRORMSG("Error in Cyclotron::readFieldMap() !" << endl);
ERRORMSG(" Not enough data in" << filename_m << ", please check data format." << endl);
exit(1);
throw GeneralClassicException("RFCavity::initialise",
"not enough data in file '" + filename_m + "', please check the data format");
}
in >> RNormal_m[i] >> VrNormal_m[i] >> DvDr_m[i];
......@@ -736,8 +735,8 @@ double RFCavity::spline(double z, double *za) {
// domain-test and handling of case "1-support-point"
if(num_points_m < 1) {
printf("Error in RFCavity::SPLINT(): No Support-Points ! \n");
exit(1);
throw GeneralClassicException("RFCavity::spline",
"no support points!");
}
if(num_points_m == 1) {
splint = RNormal_m[0];
......@@ -1045,4 +1044,4 @@ pair<double, double> RFCavity::trackOnAxisParticle(const double &p0,
const double tErr = (z - zend) / (Physics::c * beta);
return pair<double, double>(p, t - tErr);
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
#include "Ippl.h"
#include "Utilities/Options.h"
#include "AbstractObjects/OpalData.h"
#include "Utilities/GeneralClassicException.h"
LossDataSink::LossDataSink(std::string elem, bool hdf5Save):
element_m(elem),
......@@ -61,8 +62,8 @@ void LossDataSink::openH5() {
#endif
if(H5file_m == (void*)H5_ERR) {
ERRORMSG("h5 file open failed: exiting!" << endl);
exit(0);
throw GeneralClassicException("LossDataSink::openH5",
"failed to open h5 file '" + fn_m + "'");
}
}
......@@ -105,7 +106,7 @@ void LossDataSink::writeHeaderH5() {
rc = H5WriteFileAttribString(H5file_m, "turnUnit", "1");
if(rc != H5_SUCCESS)
ERRORMSG("H5 rc= " << rc << " in " << __FILE__ << " @ line " << __LINE__ << endl);
rc = H5WriteFileAttribString(H5file_m, "timeUnit", "s");
if(rc != H5_SUCCESS)
ERRORMSG("H5 rc= " << rc << " in " << __FILE__ << " @ line " << __LINE__ << endl);
......@@ -296,7 +297,7 @@ void LossDataSink::saveH5() {
rc = H5PartWriteDataFloat64(H5file_m, "time", farray);
if(rc != H5_SUCCESS)
ERRORMSG("H5 rc= " << rc << " in " << __FILE__ << " @ line " << __LINE__ << endl);
for(size_t i = 0; i < nLoc; i++)
larray[i] = turn_m[i];
rc = H5PartWriteDataInt64(H5file_m, "turn", larray);
......@@ -431,4 +432,4 @@ void LossDataSink::saveASCII() {
if(! res)
ERRORMSG("LossDataSink Ippl::Comm->send(smsg, 0, tag) failed " << endl;);
}
}
}
\ No newline at end of file
......@@ -380,7 +380,7 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) {
} else {
throw OpalException("Error in ParallelCyclotronTracker::visitCyclotron",
throw OpalException("Error in ParallelCyclotronTracker::visitCyclotron",
"Pt imaginary!");
}
......@@ -396,7 +396,7 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) {
// Restart a run:
} else {
// If the user wants to save the restarted run in local frame,
// If the user wants to save the restarted run in local frame,
// make sure the previous h5 file was local too
if (Options::psDumpLocalFrame) {
......@@ -404,18 +404,18 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) {
throw OpalException("Error in ParallelCyclotronTracker::visitCyclotron",
"You are trying a local restart from a global h5 file!");
}
// Else, if the user wants to save the restarted run in global frame,
}
// Else, if the user wants to save the restarted run in global frame,
// make sure the previous h5 file was global too
} else {
if (previousH5Local) {
throw OpalException("Error in ParallelCyclotronTracker::visitCyclotron",
"You are trying a global restart from a local h5 file!");
}
}
}
// Adjust some of the reference variables from the h5 file
referencePhi *= PIOVER180;
referencePsi *= PIOVER180;
......@@ -423,7 +423,7 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) {
if(referenceTheta <= -180.0 || referenceTheta > 180.0) {
throw OpalException("Error in ParallelCyclotronTracker::visitCyclotron",
throw OpalException("Error in ParallelCyclotronTracker::visitCyclotron",
"PHIINIT is out of [-180, 180)!");
}
}
......@@ -1094,8 +1094,8 @@ void ParallelCyclotronTracker::execute() {
*gmsg << "* Multiple time stepping (MTS) integrator" << endl;
Tracker_MTS();
} else {
*gmsg << "ERROR: Invalid name of TIMEINTEGRATOR in Track command" << endl;
exit(1);
throw OpalException("ParallelTTracker::execute",
"Invalid name of TIMEINTEGRATOR in Track command");
}
*gmsg << "* ----------------------------------------------- *" << endl;
*gmsg << "* Finalizing i.e. write data and close files :" << endl;
......@@ -3650,7 +3650,7 @@ void ParallelCyclotronTracker::Tracker_Generic() {
// Here is global frame, don't do itsBunch->boundp();
// Check separately for phase space (ps) and statistics (stat) data dump frequency
// Check separately for phase space (ps) and statistics (stat) data dump frequency
if((((step_m + 1) % Options::psDumpFreq == 0) && initialTotalNum_m != 2)
|| (doDumpAfterEachTurn && dumpEachTurn && initialTotalNum_m != 2)) {
......@@ -3712,7 +3712,7 @@ void ParallelCyclotronTracker::Tracker_Generic() {
if(initialTotalNum_m == 1) closeFiles();
// Print out the Bunch information at end of the run. Because the bunch information
// Print out the Bunch information at end of the run. Because the bunch information
// displays in units of m we have to change back and forth one more time.
// Furthermore it is my opinion that the same units should be used throughout OPAL. -DW
itsBunch->R *= Vector_t(0.001); // mm --> m
......@@ -4555,7 +4555,7 @@ void ParallelCyclotronTracker::repartition() {
}
}
void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particleVectors,
void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particleVectors,
double phi, Vector_t const translationToGlobal) {
particleVectors -= translationToGlobal;
......@@ -4569,7 +4569,7 @@ void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particle
}
}
void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & particleVectors,
void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & particleVectors,
double phi, Vector_t const translationToGlobal) {
Tenzor<double, 3> const rotation(cos(phi), -sin(phi), 0,
......@@ -4585,8 +4585,8 @@ void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & particle
}
inline void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particleVectors,
Quaternion_t const quaternion,
inline void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particleVectors,
Quaternion_t const quaternion,
Vector_t const meanR) {
// Translation from global to local
......@@ -4596,8 +4596,8 @@ inline void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & p
rotateWithQuaternion(particleVectors, quaternion);
}
inline void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & particleVectors,
Quaternion_t const quaternion,
inline void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & particleVectors,
Quaternion_t const quaternion,
Vector_t const meanR) {
// Reverse the quaternion by multiplying the axis components (x,y,z) with -1
......@@ -4611,9 +4611,9 @@ inline void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & p
particleVectors += meanR;
}
inline void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particleVectors,
double const phi,
double const psi,
inline void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & particleVectors,
double const phi,
double const psi,
Vector_t const meanR) {
//double const tolerance = 1.0e-4; // TODO What is a good angle threshold? -DW
......@@ -4630,9 +4630,9 @@ inline void ParallelCyclotronTracker::globalToLocal(ParticleAttrib<Vector_t> & p
rotateAroundX(particleVectors, psi);
}
inline void ParallelCyclotronTracker::globalToLocal(Vector_t & myVector,
double const phi,
double const psi,
inline void ParallelCyclotronTracker::globalToLocal(Vector_t & myVector,
double const phi,
double const psi,
Vector_t const meanR) {
//double const tolerance = 1.0e-4; // TODO What is a good angle threshold? -DW
......@@ -4649,9 +4649,9 @@ inline void ParallelCyclotronTracker::globalToLocal(Vector_t & myVector,
rotateAroundX(myVector, psi);
}
inline void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & particleVectors,
double const phi,
double const psi,
inline void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & particleVectors,
double const phi,
double const psi,
Vector_t const meanR) {
//double const tolerance = 1.0e-4; // TODO What is a good angle threshold? -DW
......@@ -4668,9 +4668,9 @@ inline void ParallelCyclotronTracker::localToGlobal(ParticleAttrib<Vector_t> & p
particleVectors += meanR;
}
inline void ParallelCyclotronTracker::localToGlobal(Vector_t & myVector,
double const phi,
double const psi,
inline void ParallelCyclotronTracker::localToGlobal(Vector_t & myVector,
double const phi,
double const psi,
Vector_t const meanR) {
//double const tolerance = 1.0e-4; // TODO What is a good angle threshold? -DW
......@@ -5102,9 +5102,9 @@ void ParallelCyclotronTracker::initDistInGlobalFrame() {
// Else: Restart from the distribution in the h5 file
} else {
// Do a local frame restart (we have already checked that the old h5 file was saved in local
// frame as well).
// frame as well).
// Cave: Multi-bunch must not be done in the local frame! (TODO: Is this still true? -DW)
if((Options::psDumpLocalFrame)) {
......@@ -5117,7 +5117,7 @@ void ParallelCyclotronTracker::initDistInGlobalFrame() {
Vector_t const initMeanR = Vector_t(referenceR * cosRefTheta_m,
referenceR * sinRefTheta_m,
referenceZ);
// Do the tranformations
localToGlobal(itsBunch->R, referencePhi, referencePsi, initMeanR);
localToGlobal(itsBunch->P, referencePhi, referencePsi);
......@@ -5198,7 +5198,7 @@ void ParallelCyclotronTracker::initDistInGlobalFrame() {
step_m += 1;
}
// Print out the Bunch information at beginning of the run. Because the bunch information
// Print out the Bunch information at beginning of the run. Because the bunch information
// displays in units of m we have to change back and forth one more time.
// Furthermore it is my opinion that the same units should be used throughout OPAL. -DW
itsBunch->R *= Vector_t(0.001); // mm --> m
......@@ -5360,17 +5360,17 @@ void ParallelCyclotronTracker::bunchDumpStatData(){
// If we are saving in local frame, bunch and fields at the bunch center have to be rotated
// TODO: Make decision if we maybe want to always save statistics data in local frame? -DW
if(Options::psDumpLocalFrame) {
if(Options::psDumpLocalFrame) {
// -------------------- ----------- Do Transformations ---------------------------------- //
// Bunch (local) azimuth at meanR w.r.t. y-axis
phi = calculateAngle(meanP(0), meanP(1)) - 0.5 * pi;
// Bunch (local) elevation at meanR w.r.t. xy plane
psi = 0.5 * pi - acos(meanP(2) / sqrt(dot(meanP, meanP)));
// Rotate so Pmean is in positive y direction. No shift, so that normalized emittance and
// unnormalized emittance as well as centroids are calculated correctly in
// Rotate so Pmean is in positive y direction. No shift, so that normalized emittance and
// unnormalized emittance as well as centroids are calculated correctly in
// PartBunch::calcBeamParameters()
globalToLocal(extB_m, phi, psi);
globalToLocal(extE_m, phi, psi);
......@@ -5386,7 +5386,7 @@ void ParallelCyclotronTracker::bunchDumpStatData(){
// If we are in local mode, transform back after saving
if(Options::psDumpLocalFrame) {
localToGlobal(itsBunch->R, phi, psi);
localToGlobal(itsBunch->P, phi, psi);
}
......@@ -5406,7 +5406,7 @@ void ParallelCyclotronTracker::bunchDumpPhaseSpaceData() {
// --------------------------------- Get some Values ---------------------------------------- //
double const temp_t = itsBunch->getT() * 1.0e9; // s -> ns
Vector_t const meanR = calcMeanR();
Vector_t const meanP = calcMeanP();
......@@ -5448,8 +5448,8 @@ void ParallelCyclotronTracker::bunchDumpPhaseSpaceData() {
itsBunch->R *= Vector_t(0.001); // mm --> m
// -------------- If flag DumpLocalFrame is not set, dump bunch in global frame ------------- //
if(!(Options::psDumpLocalFrame)) {
if(!(Options::psDumpLocalFrame)) {
FDext_m[0] = extB_m * 0.1; // kgauss --> T
FDext_m[1] = extE_m;
......@@ -5461,16 +5461,16 @@ void ParallelCyclotronTracker::bunchDumpPhaseSpaceData() {
referenceR,
referenceTheta,
referenceZ,
phi / PIOVER180, // P_mean azimuth
phi / PIOVER180, // P_mean azimuth
// at ref. R/Th/Z
psi / PIOVER180, // P_mean elevation
psi / PIOVER180, // P_mean elevation
// at ref. R/Th/Z
false); // Flag localFrame
// Tell user in which mode we are dumping
*gmsg << endl << "* Phase space dump " << lastDumpedStep_m
<< " (global frame) at integration step " << step_m + 1 << endl;
}
}
// ---------------- If flag DumpLocalFrame is set, dump bunch in local frame ---------------- //
else {
......@@ -5480,7 +5480,7 @@ void ParallelCyclotronTracker::bunchDumpPhaseSpaceData() {
globalToLocal(itsBunch->P, phi, psi); // P should only be rotated
globalToLocal(extB_m, phi, psi);
globalToLocal(extE_m, phi, psi);
globalToLocal(extE_m, phi, psi);
FDext_m[0] = extB_m * 0.1; // kgauss --> T
FDext_m[1] = extE_m;
......@@ -5493,9 +5493,9 @@ void ParallelCyclotronTracker::bunchDumpPhaseSpaceData() {
referenceR,
referenceTheta,
referenceZ,
phi / PIOVER180, // P_mean azimuth
phi / PIOVER180, // P_mean azimuth
// at ref. R/Th/Z
psi / PIOVER180, // P_mean elevation
psi / PIOVER180, // P_mean elevation
// at ref. R/Th/Z
true); // Flag localFrame
......@@ -5559,4 +5559,4 @@ void ParallelCyclotronTracker::evaluateSpaceChargeField() {
localToGlobal(itsBunch->Bf, phi);
localToGlobal(itsBunch->R, phi, meanR);
}
}
}
\ No newline at end of file
#include "Elements/OpalBeamline.h"
#include "Utilities/OpalException.h"
using namespace std;
......@@ -385,8 +386,8 @@ void OpalBeamline::prepareSections() {
start_end.sort();
if(start_end.size() == 0) {
ERRORMSG("no valid elements found; will exit now" << endl);
exit(1);
throw OpalException("OpalBeamline::prepareSections",
"no valid elements found");
}
next_it = start_end.begin();
......@@ -496,4 +497,4 @@ FieldList OpalBeamline::getElementByType(const std::string type) {
}
}
return elements_of_requested_type;
}
}
\ No newline at end of file
......@@ -109,8 +109,8 @@ MGPoissonSolver::MGPoissonSolver ( PartBunch &beam,
bp = new BoxCornerDomain(currentGeometry->getA(), currentGeometry->getB(), currentGeometry->getC(), currentGeometry->getLength(),currentGeometry->getL1(), currentGeometry->getL2(), orig_nr_m, hr_m, interpl);
bp->Compute(itsBunch_m->get_hr());
} else {
ERRORMSG("Geometry not known" << endl);
exit(1);
throw OpalException("MGPoissonSolver::MGPoissonSolver",
"Geometry not known");
}
} else
bp = new ArbitraryDomain(currentGeometry, orig_nr_m, hr_m, interpl);
......@@ -569,4 +569,4 @@ Inform &MGPoissonSolver::print(Inform &os) const {
return os;
}
#endif /* HAVE_SAAMG_SOLVER */
#endif /* HAVE_SAAMG_SOLVER */
\ No newline at end of file
......@@ -44,7 +44,7 @@ DataSink::DataSink() :
firstWriteH5Surface_m = true;
/// Define file names.
string fn = OpalData::getInstance()->getInputBasename();
surfacLossFileName_m = fn + string(".SurfaceLoss.h5");
surfaceLossFileName_m = fn + string(".SurfaceLoss.h5");
statFileName_m = fn + string(".stat");
lBalFileName_m = fn + string(".lbal");
......@@ -60,8 +60,8 @@ DataSink::DataSink() :
H5file_m = H5OpenFile(fn.c_str(), H5_FLUSH_STEP | H5_O_WRONLY, 0);
#endif
if (H5file_m == (void*)H5_ERR) {
ERRORMSG("h5 file " << fn.c_str() << " open failed: exiting!" << endl);
exit(0);
throw OpalException("DataSink::DataSink()",
"failed to open h5 file '" + fn + "'");
}
/// Write file attributes.
writeH5FileAttributes();
......@@ -79,8 +79,8 @@ DataSink::DataSink(int restartStep) :
{
doHDF5_m = Options::enableHDF5;
if (!doHDF5_m) {
ERRORMSG ("Can not restart when HDF5 is disabled" << endl);
exit(1);
throw OpalException("DataSink::DataSink(int)",
"Can not restart when HDF5 is disabled");
}
/// Constructor steps:
h5_int64_t rc;
......@@ -128,8 +128,8 @@ DataSink::DataSink(int restartStep) :
*gmsg << "Will append to " << fn << endl;
if(H5file_m == (void*)H5_ERR) {
ERRORMSG("h5 file open failed: exiting!" << endl);
exit(0);
throw OpalException("DataSink::DataSink(int)",
"failed to open h5 file '" + fn + "'");
}
int numStepsInFile = H5GetNumSteps(H5file_m);
......@@ -976,7 +976,7 @@ int DataSink::writePhaseSpace_cycl(PartBunch &beam, Vector_t FDext[], double mea
h5_int64_t globalTrackStep = (h5_int64_t)beam.getGlobalTrackStep();
h5_int64_t numBunch = (h5_int64_t)beam.getNumBunch();
h5_int64_t SteptoLastInj = (h5_int64_t)beam.getSteptoLastInj();
h5_int64_t localFrame = 0;
if (local) localFrame = 1;
......@@ -2357,14 +2357,14 @@ void DataSink::writeSurfaceInteraction(PartBunch &beam, long long &step, Boundar
if(firstWriteH5Surface_m) {
firstWriteH5Surface_m = false;
#ifdef PARALLEL_IO
H5fileS_m = H5OpenFile(surfacLossFileName_m.c_str(), H5_FLUSH_STEP | H5_O_WRONLY, Ippl::getComm());
H5fileS_m = H5OpenFile(surfaceLossFileName_m.c_str(), H5_FLUSH_STEP | H5_O_WRONLY, Ippl::getComm());
#else
H5fileS_m = H5OpenFile(surfacLossFileName_m.c_str(), H5_FLUSH_STEP | H5_O_WRONLY, 0);
H5fileS_m = H5OpenFile(surfaceLossFileName_m.c_str(), H5_FLUSH_STEP | H5_O_WRONLY, 0);
#endif
if(H5fileS_m == (void*)H5_ERR) {
ERRORMSG("h5 file for surface loss open failed: exiting!" << endl);
exit(0);
throw OpalException("DataSink::writeSurfaceInteraction",
"failed to open h5 file '" + surfaceLossFileName_m + "' for surface loss");
}
......@@ -2598,8 +2598,8 @@ void DataSink::storeOneBunch(const PartBunch &beam, const string fn_appendix) {
#endif
if(H5file == (void*)H5_ERR) {
ERRORMSG("h5 file for backup bunch in OPAL-CYCL open failed: exiting!" << endl);
exit(0);
throw OpalException("DataSink::storeOneBunch",
"failed to open h5 file '" + fn + "' for backup bunch in OPAL-CYCL");
}
h5_int64_t H5call = 0;
......@@ -2729,8 +2729,8 @@ bool DataSink::readOneBunch(PartBunch &beam, const string fn_appendix, const siz
H5file = H5OpenFile(fn.c_str(), H5_O_RDONLY);
#endif
if(H5file == (void*)H5_ERR) {
ERRORMSG("File open failed: exiting!" << endl);
exit(0);
throw OpalException("DataSink::readOneBunch",
"failed to open h5 file '" + fn + "'");
}
h5_int64_t H5call = 0;
......@@ -2895,4 +2895,4 @@ void DataSink::setOPALt() {
/***************************************************************************
* $RCSfile: DataSink.cpp,v $ $Author: adelmann $
* $Revision: 1.3 $ $Date: 2004/06/02 19:38:54 $
***************************************************************************/
***************************************************************************/
\ No newline at end of file
......@@ -292,7 +292,7 @@ private:
h5_file_t *H5file_m;
/// Name of output file for surface loss data.
std::string surfacLossFileName_m;
std::string surfaceLossFileName_m;
/// %Pointer to H5 file for surface loss data.
h5_file_t *H5fileS_m;
......