Commit 37a2ca48 authored by frey_m's avatar frey_m

Merge branch '401-closed-orbit-finder-should-not-call-exit' into 'master'

Resolve "Closed Orbit Finder should not call exit()"

Closes #401

See merge request !215
parents 8239ed3d fd714c64
......@@ -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
......
//
// Implements the member function of the EarlyLeaveException class.
//
// Copyright (c) 2008-2019
// Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved.
//
// OPAL is licensed under GNU GPL version 3.
//
#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()
{}
//
// This exception class is used to intentionally exit OPAL even if no
// error occurred. It is used in case of the tune calculation with
// the matched distribution option.
//
// Copyright (c) 2008-2019
// Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved.
//
// OPAL is licensed under GNU GPL version 3.
//
#ifndef OPAL_EARLY_LEAVE_EXCEPTION_H
#define OPAL_EARLY_LEAVE_EXCEPTION_H
#include "Utilities/ClassicException.h"
/*!
This exception class is used to inentionally exit OPAL when no error occurred.
*/
class EarlyLeaveException: public ClassicException {
public:
/** The usual constructor.
* @param[in] meth the name of the method or function detecting the exception
* @param[in] msg the message string identifying the exception
*/
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() = delete;
};
#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