Commit 3a663fd8 authored by frey_m's avatar frey_m

add new execption class to remove std::exit

parent 8239ed3d
......@@ -40,6 +40,7 @@
#include "Structure/H5PartWrapper.h"
#include "Structure/H5PartWrapperForPC.h"
#include "Utilities/Util.h"
#include "Utilities/EarlyLeaveException.h"
#include <gsl/gsl_cdf.h>
#include <gsl/gsl_randist.h>
......@@ -1348,7 +1349,8 @@ void Distribution::createMatchedGaussDistribution(size_t numberOfParticles, doub
cof_t cof(massIneV*1E-6, Nint, CyclotronElement, false, Nsectors);
cof.findOrbit(accuracy, maxitCOF, E_m*1E-6, denergy, rguess, true);
std::exit(0);
throw EarlyLeaveException("Distribution::CreateMatchedGaussDistribution()",
"Do only tune calculation.");
}
bool writeMap = true;
......
......@@ -35,6 +35,7 @@ Inform *gmsg;
#include "Utilities/Options.h"
#include "Utilities/Options.h"
#include "Utilities/OpalException.h"
#include "Utilities/EarlyLeaveException.h"
#include "Utilities/Util.h"
#include "OPALconfig.h"
......@@ -361,13 +362,6 @@ int main(int argc, char *argv[]) {
}
}
IpplTimings::stopTimer(mainTimer);
IpplTimings::print();
IpplTimings::print(std::string("timing.dat"),
OpalData::getInstance()->getProblemCharacteristicValues());
if(Ippl::myNode() == 0) {
std::ifstream errormsg("errormsg.txt");
if(errormsg.good()) {
......@@ -398,25 +392,8 @@ int main(int argc, char *argv[]) {
errormsg.close();
}
Ippl::Comm->barrier();
Fieldmap::clearDictionary();
OpalData::deleteInstance();
delete gmsg;
#ifdef ENABLE_AMR
if ( initAMR ) {
amrex::Finalize(true);
}
#endif
delete ippl;
delete Ippl::Info;
delete Ippl::Warn;
delete Ippl::Error;
delete Ippl::Debug;
return 0;
} catch(EarlyLeaveException& ex) {
// do nothing here
} catch(OpalException &ex) {
Inform errorMsg("Error", std::cerr, INFORM_ALL_NODES);
errorMsg << "\n*** User error detected by function \""
......@@ -524,5 +501,30 @@ int main(int argc, char *argv[]) {
MPI_Abort(MPI_COMM_WORLD, -100);
}
return 1;
IpplTimings::stopTimer(mainTimer);
IpplTimings::print();
IpplTimings::print(std::string("timing.dat"),
OpalData::getInstance()->getProblemCharacteristicValues());
Ippl::Comm->barrier();
Fieldmap::clearDictionary();
OpalData::deleteInstance();
delete gmsg;
#ifdef ENABLE_AMR
if ( initAMR ) {
amrex::Finalize(true);
}
#endif
delete ippl;
delete Ippl::Info;
delete Ippl::Warn;
delete Ippl::Error;
delete Ippl::Debug;
return 0;
}
\ No newline at end of file
set (_SRCS
EarlyLeaveException.cpp
OpalException.cpp
OpalFilter.cpp
RegularExpression.cpp
......@@ -15,6 +16,7 @@ include_directories (
add_opal_sources(${_SRCS})
set (HDRS
EarlyLeaveException.h
NumToStr.h
OpalException.h
OpalFilter.h
......
#include "Utilities/EarlyLeaveException.h"
EarlyLeaveException::EarlyLeaveException(const std::string &meth, const std::string &msg):
ClassicException(meth, msg)
{}
EarlyLeaveException::EarlyLeaveException(const EarlyLeaveException &rhs):
ClassicException(rhs)
{}
EarlyLeaveException::~EarlyLeaveException()
{}
#ifndef OPAL_EARLY_LEAVE_EXCEPTION_HH
#define OPAL_EARLY_LEAVE_EXCEPTION_HH
#include "Utilities/ClassicException.h"
class EarlyLeaveException: public ClassicException {
public:
/// The usual constructor.
// Arguments:
// [DL]
// [DT][b]meth[/b]
// [DD]the name of the method or function detecting the exception
// [DT][b]msg [/b]
// [DD]the message string identifying the exception
// [/DL]
explicit EarlyLeaveException(const std::string &meth, const std::string &msg);
EarlyLeaveException(const EarlyLeaveException &);
virtual ~EarlyLeaveException();
/// Return the message string for the exception.
using ClassicException::what;
/// Return the name of the method or function which detected the exception.
using ClassicException::where;
private:
// Not implemented.
EarlyLeaveException();
};
#endif
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