Commit 03f228c9 authored by kraus's avatar kraus
Browse files

fixing memory leak in IpplInfo

parent cc1bea27
......@@ -63,6 +63,22 @@ void IpplInfo::instantiateGlobals() {
Debug = new Inform("**DEBUG**", std::cerr, INFORM_ALL_NODES);
}
void IpplInfo::deleteGlobals() {
delete Comm;
delete Stats;
delete Info;
delete Warn;
delete Error;
delete Debug;
Comm = 0;
Stats = 0;
Info = 0;
Warn = 0;
Error = 0;
Debug = 0;
}
std::stack<StaticIpplInfo> IpplInfo::stashedStaticMembers;
//dks base member of IpplInfo initialized to default values
......@@ -641,7 +657,7 @@ IpplInfo::~IpplInfo() {
// dbgmsg << " Deleting comm object, since now NumCreated = ";
// dbgmsg << NumCreated << endl;
delete Comm;
Comm = 0;
NeedDeleteComm = false;
}
CommInitialized = false;
......@@ -1125,8 +1141,8 @@ void IpplInfo::stash() {
Comm = 0;
Stats = 0;
// can't set Info and Warn to zero since
// IpplInfoWrapper requires valid objects
Info = 0;
Warn = 0;
Error = 0;
Debug = 0;
......
......@@ -318,6 +318,7 @@ public:
static void printStatistics(Inform&);
static void instantiateGlobals();
static void deleteGlobals();
private:
static MPI_Comm communicator_m;
......@@ -415,4 +416,4 @@ typedef IpplInfo Ippl;
* $RCSfile: IpplInfo.h,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:33 $
* IPPL_VERSION_ID: $Id: IpplInfo.h,v 1.1.1.1 2003/01/23 07:40:33 adelmann Exp $
***************************************************************************/
***************************************************************************/
\ No newline at end of file
......@@ -148,7 +148,7 @@ void StatisticalErrors::execute() {
}
void StatisticalErrors::runSimulation(const std::string &inputFileName, MPI_Comm comm) {
IpplInfoWrapper *newippl = new IpplInfoWrapper(inputFileName, comm);
IpplInfoWrapper *newippl = new IpplInfoWrapper(inputFileName, Options::infoLevel, Options::warnLevel, comm);
std::string::size_type startExtension = inputFileName.find_last_of('.');
std::string::size_type startRelativePath = inputFileName.find_last_of('/');
std::string relativePath("");
......@@ -1074,4 +1074,4 @@ std::pair<int, int> StatisticalErrors::getNextObjectiveToProcess(int tag, char *
memcpy(reinterpret_cast<char*>(&nextJob.second), messageBuffer + sizeof(int), sizeof(int));
return nextJob;
}
}
\ No newline at end of file
......@@ -6,6 +6,9 @@ namespace Options {
// The global program options.
bool echo = false;
bool info = true;
int infoLevel = 1;
bool warn = true;
int warnLevel = 1;
bool csrDump = false;
bool ppdebug = false;
......@@ -27,7 +30,6 @@ namespace Options {
// The global program options.
bool mtrace = false;
bool warn = true;
bool psDumpEachTurn = false;
DumpFrame psDumpFrame = GLOBAL;
bool rhoDump = false;
......
......@@ -36,6 +36,14 @@ namespace Options {
// If true, print informative messages.
extern bool info;
extern int infoLevel;
/// Warn flag.
// If true, print warning messages.
extern bool warn;
extern int warnLevel;
extern bool csrDump;
/// ppdebug flag.
......@@ -66,10 +74,6 @@ namespace Options {
// If true, print CPU time before and after each command.
extern bool mtrace;
/// Warn flag.
// If true, print warning messages.
extern bool warn;
/// Random generator.
// The global random generator.
extern Random rangen;
......
......@@ -291,7 +291,7 @@ void OpalSimulation::run() {
// std::cerr.setstate(std::ios::failbit);
#endif
// now we can run the simulation
run_opal(arg, inputFileName.str(), -1, comm_);
run_opal(arg, inputFileName.str(), -1, Options::infoLevel, Options::warnLevel, comm_);
//restoreOut();
#ifdef SUPRESS_OUTPUT
......
......@@ -4,28 +4,28 @@
#include "Structure/IpplInfoWrapper.h"
IpplInfoWrapper::IpplInfoWrapper(const std::string &inputFileName, MPI_Comm comm) {
std::string infoLevel = std::to_string(Ippl::Info->getOutputLevel());
std::string warnLevel = std::to_string(Ippl::Warn->getOutputLevel());
IpplInfoWrapper::IpplInfoWrapper(const std::string &inputFileName, int infoLevel, int warnLevel, MPI_Comm comm) {
std::string infoLevelStr = std::to_string(infoLevel);
std::string warnLevelStr = std::to_string(warnLevel);
exeName_m = 0;
inputFileName_m = exeName_m + 5;
noComm_m = inputFileName_m + inputFileName.size() + 1;
info_m = noComm_m + 13;
infoLevel_m = info_m + 7;
warn_m = infoLevel_m + infoLevel.size() + 1;
warn_m = infoLevel_m + infoLevelStr.size() + 1;
warnLevel_m = warn_m + 7;
unsigned int totalSize = warnLevel_m + warnLevel.size() + 1;
unsigned int totalSize = warnLevel_m + warnLevelStr.size() + 1;
buffer_m = new char[totalSize];
strcpy(buffer_m + exeName_m, "opal");
strcpy(buffer_m + inputFileName_m, inputFileName.c_str());
strcpy(buffer_m + noComm_m, "--nocomminit");
strcpy(buffer_m + info_m, "--info");
strcpy(buffer_m + infoLevel_m, infoLevel.c_str());
strcpy(buffer_m + infoLevel_m, infoLevelStr.c_str());
strcpy(buffer_m + warn_m, "--warn");
strcpy(buffer_m + warnLevel_m, warnLevel.c_str());
strcpy(buffer_m + warnLevel_m, warnLevelStr.c_str());
arg_m = new char*[7];
arg_m[0] = buffer_m + exeName_m;
......@@ -44,4 +44,6 @@ IpplInfoWrapper::~IpplInfoWrapper() {
delete instance_m;
delete[] buffer_m;
delete[] arg_m;
Ippl::deleteGlobals();
}
\ No newline at end of file
......@@ -13,7 +13,7 @@
class IpplInfoWrapper {
public:
IpplInfoWrapper(const std::string &inputFileName, MPI_Comm comm);
IpplInfoWrapper(const std::string &inputFileName, int infoLevel, int warnLevel, MPI_Comm comm);
~IpplInfoWrapper();
private:
......
......@@ -15,7 +15,7 @@ extern Inform *gmsg;
#include "OPALconfig.h"
int run_opal(char *arg[], std::string inputfile, int restartStep, MPI_Comm comm) {
int run_opal(char *arg[], std::string inputfile, int restartStep, int infoLevel, int warnLevel, MPI_Comm comm) {
std::string::size_type startExtension = inputfile.find_last_of('.');
// std::string::size_type startRelativePath = inputfile.find_last_of('/');
......@@ -28,7 +28,7 @@ int run_opal(char *arg[], std::string inputfile, int restartStep, MPI_Comm comm)
MPI_Barrier(comm);
IpplInfoWrapper *newippl = new IpplInfoWrapper(inputfile, comm);
IpplInfoWrapper *newippl = new IpplInfoWrapper(inputfile, infoLevel, warnLevel, comm);
gmsg = new Inform("OPAL ", output);
IpplInfo::Info->setDestination(output);
IpplInfo::Error->setDestination(output);
......
......@@ -4,6 +4,6 @@
#include "Ippl.h"
int run_opal(char *arg[], std::string inputfile, int restartStep = -1, MPI_Comm comm = MPI_COMM_WORLD);
int run_opal(char *arg[], std::string inputfile, int restartStep = -1, int infoLevel = 1, int warnLevel = 1, MPI_Comm comm = MPI_COMM_WORLD);
#endif
#endif
\ No newline at end of file
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