From 0a08450bfae3922f066c1ed1105dda4ee15abc14 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 28 May 2019 13:51:53 +0200 Subject: [PATCH] move testout to ngcore --- libsrc/core/logging.cpp | 1 + libsrc/core/logging.hpp | 2 ++ libsrc/general/template.hpp | 1 - libsrc/include/nginterface.h | 1 - libsrc/meshing/global.cpp | 1 - ng/ngappinit.cpp | 7 +++++-- ng/parallelfunc.cpp | 7 +++++-- nglib/nglib.cpp | 2 +- 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libsrc/core/logging.cpp b/libsrc/core/logging.cpp index eaaedf02..a39554f8 100644 --- a/libsrc/core/logging.cpp +++ b/libsrc/core/logging.cpp @@ -13,6 +13,7 @@ namespace ngcore { + std::ostream* testout = new std::ostream(nullptr); // NOLINT void Logger::log(level::level_enum level, std::string && s) { diff --git a/libsrc/core/logging.hpp b/libsrc/core/logging.hpp index 1553ad54..cbbbea99 100644 --- a/libsrc/core/logging.hpp +++ b/libsrc/core/logging.hpp @@ -31,6 +31,8 @@ namespace spdlog namespace ngcore { + NGCORE_API extern std::ostream* testout; // NOLINT + namespace level { enum level_enum diff --git a/libsrc/general/template.hpp b/libsrc/general/template.hpp index 8f824a9b..4cb73173 100644 --- a/libsrc/general/template.hpp +++ b/libsrc/general/template.hpp @@ -23,7 +23,6 @@ namespace netgen // #include /** output stream for testing. testout is opened by main */ -DLL_HEADER extern ostream * testout; /** use instead of cout */ DLL_HEADER extern ostream * mycout; diff --git a/libsrc/include/nginterface.h b/libsrc/include/nginterface.h index 3398d072..0a0a276f 100644 --- a/libsrc/include/nginterface.h +++ b/libsrc/include/nginterface.h @@ -483,7 +483,6 @@ extern "C" { #include namespace netgen { - DLL_HEADER extern std::ostream * testout; DLL_HEADER extern int printmessage_importance; } diff --git a/libsrc/meshing/global.cpp b/libsrc/meshing/global.cpp index 18092496..e614e1bd 100644 --- a/libsrc/meshing/global.cpp +++ b/libsrc/meshing/global.cpp @@ -18,7 +18,6 @@ namespace netgen // testout -> clear(ios::failbit); // ostream * testout = &cout; - ostream * testout = new ostream(0); // NetgenOutStream * testout = new NetgenOutStream; diff --git a/ng/ngappinit.cpp b/ng/ngappinit.cpp index 43ff1afd..04faa4b7 100644 --- a/ng/ngappinit.cpp +++ b/ng/ngappinit.cpp @@ -146,8 +146,11 @@ int main(int argc, char ** argv) if ( netgen::id == 0 ) { - if (parameters.StringFlagDefined ("testout")) - netgen::testout = new ofstream (parameters.GetStringFlag ("testout", "test.out")); + if (parameters.StringFlagDefined ("testout")) + { + delete ngcore::testout; + ngcore::testout = new ofstream (parameters.GetStringFlag ("testout", "test.out")); + } #ifdef SOCKETS diff --git a/ng/parallelfunc.cpp b/ng/parallelfunc.cpp index 6c7498ac..28d7de5a 100644 --- a/ng/parallelfunc.cpp +++ b/ng/parallelfunc.cpp @@ -71,8 +71,11 @@ void ParallelRun() MPI_Comm_size(MPI_COMM_WORLD, &ntasks); MPI_Comm_rank(MPI_COMM_WORLD, &id); - if (parameters.StringFlagDefined ("testout")) - testout = new ofstream (string("testout_proc") + id ); + if (parameters.StringFlagDefined ("testout")) + { + delete testout; + testout = new ofstream (string("testout_proc") + id ); + } diff --git a/nglib/nglib.cpp b/nglib/nglib.cpp index 54fff096..da2cc05b 100644 --- a/nglib/nglib.cpp +++ b/nglib/nglib.cpp @@ -82,7 +82,7 @@ namespace nglib mycout = &cout; myerr = &cerr; // netgen::testout->SetOutStream (new ofstream ("test.out")); - testout = new ofstream ("test.out"); + // testout = new ofstream ("test.out"); }