From d9e789cd3f67d0e883ab849a476360be367627a2 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 5 Dec 2025 13:30:23 +0000 Subject: [PATCH 01/34] Switch to `cpptrace` for stack traces in exceptions --- .clang-tidy | 2 +- CMakeLists.txt | 13 --- bout++Config.cmake.in | 7 +- cmake/SetupBOUTThirdParty.cmake | 16 ++++ cmake_build_defines.hxx.in | 4 +- include/bout/boutexception.hxx | 9 -- include/bout/physicsmodel.hxx | 3 +- manual/doxygen/Doxyfile | 1 - manual/doxygen/Doxyfile_readthedocs | 1 - src/sys/boutexception.cxx | 92 +++++-------------- .../integrated/test-backtrace/CMakeLists.txt | 4 +- tests/integrated/test-backtrace/runtest | 4 +- tests/unit/sys/test_boutexception.cxx | 25 ++--- 13 files changed, 61 insertions(+), 120 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 23167e93d0..cf29b759cd 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -20,7 +20,7 @@ CheckOptions: value: 'MPI_Comm' - key: misc-include-cleaner.IgnoreHeaders - value: 'adios2/.*;bits/.*' + value: 'adios2/.*;bits/.*;cpptrace/.*' --- Disabled checks and reasons: diff --git a/CMakeLists.txt b/CMakeLists.txt index 44d100e444..7864705519 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -574,18 +574,6 @@ option(BOUT_ENABLE_SIGFPE "Signalling floating point exceptions" OFF) message(STATUS "Signalling floating point exceptions: BOUT_USE_SIGFPE=${BOUT_ENABLE_SIGFPE}") set(BOUT_USE_SIGFPE ${BOUT_ENABLE_SIGFPE}) -option(BOUT_ENABLE_BACKTRACE "Enable backtrace" ON) -if (BOUT_ENABLE_BACKTRACE) - find_program(ADDR2LINE_FOUND addr2line) - if (NOT ADDR2LINE_FOUND) - message(FATAL_ERROR "addr2line not found. Disable backtrace by setting BOUT_ENABLE_BACKTRACE=Off") - endif() - target_link_libraries(bout++ PUBLIC ${CMAKE_DL_LIBS}) - set(CONFIG_LDFLAGS "${CONFIG_LDFLAGS} -l${CMAKE_DL_LIBS}") -endif() -message(STATUS "Enable backtrace: BOUT_USE_BACKTRACE=${BOUT_ENABLE_BACKTRACE}") -set(BOUT_USE_BACKTRACE ${BOUT_ENABLE_BACKTRACE}) - option(BOUT_ENABLE_METRIC_3D "Enable 3D metric support" OFF) if(BOUT_ENABLE_METRIC_3D) set(BOUT_METRIC_TYPE "3D") @@ -958,7 +946,6 @@ message(" Output coloring : ${BOUT_USE_COLOR} Field name tracking : ${BOUT_USE_TRACK} Floating point exceptions: ${BOUT_USE_SIGFPE} - Backtrace enabled : ${BOUT_USE_BACKTRACE} RAJA enabled : ${BOUT_HAS_RAJA} Umpire enabled : ${BOUT_HAS_UMPIRE} Caliper enabled : ${BOUT_HAS_CALIPER} diff --git a/bout++Config.cmake.in b/bout++Config.cmake.in index d461e58e4b..a82479f41c 100644 --- a/bout++Config.cmake.in +++ b/bout++Config.cmake.in @@ -6,7 +6,6 @@ set(BOUT_USE_SIGNAL @BOUT_USE_SIGNAL@) set(BOUT_USE_COLOR @BOUT_USE_COLOR@) set(BOUT_USE_TRACK @BOUT_USE_TRACK@) set(BOUT_USE_SIGFPE @BOUT_USE_SIGFPE@) -set(BOUT_USE_BACKTRACE @BOUT_USE_BACKTRACE@) set(BOUT_USE_OPENMP @BOUT_USE_OPENMP@) set(BOUT_HAS_CUDA @BOUT_HAS_CUDA@) set(BOUT_HAS_OUTPUT_DEBUG @BOUT_HAS_OUTPUT_DEBUG@) @@ -109,6 +108,11 @@ elseif(EXISTS "@ADIOS2_BINARY_DIR@") # If we downloaded ADIOS2, then we need to add its build directory to our search paths list(APPEND CMAKE_PREFIX_PATH "@ADIOS2_BINARY_DIR@") endif() +if(EXISTS "@cpptrace_ROOT@") + set(cpptrace_ROOT "@cpptrace_ROOT@") +elseif(EXISTS "@cpptrace_BINARY_DIR@") + list(APPEND CMAKE_PREFIX_PATH "@cpptrace_BINARY_DIR@") +endif() if(@BOUT_USE_SYSTEM_MPARK_VARIANT@) set(mpark_variant_ROOT "@mpark_variant_ROOT@") @@ -160,6 +164,7 @@ if (BOUT_HAS_GETTEXT) endif() find_dependency(mpark_variant @mpark_variant_VERSION@) find_dependency(fmt @fmt_VERSION@) +find_dependency(cpptrace @cpptrace_VERSION@) if (BOUT_HAS_SLEPC) find_dependency(SLEPc @SLEPC_VERSION@) endif() diff --git a/cmake/SetupBOUTThirdParty.cmake b/cmake/SetupBOUTThirdParty.cmake index 1256fbbeba..2249fb3468 100644 --- a/cmake/SetupBOUTThirdParty.cmake +++ b/cmake/SetupBOUTThirdParty.cmake @@ -369,3 +369,19 @@ if (BOUT_USE_UUID_SYSTEM_GENERATOR) endif() message(STATUS "UUID_SYSTEM_GENERATOR: ${BOUT_USE_UUID_SYSTEM_GENERATOR}") set(BOUT_HAS_UUID_SYSTEM_GENERATOR ${BOUT_USE_UUID_SYSTEM_GENERATOR}) + +option(BOUT_DOWNLOAD_CPPTRACE "Download cpptrace for backtrace support" ON) +if (BOUT_DOWNLOAD_CPPTRACE) + include(FetchContent) + set(CPPTRACE_LIBDWARF_REPO "https://github.com/ZedThree/libdwarf-lite.git" CACHE STRING "" FORCE) + set(CPPTRACE_LIBDWARF_TAG "5f15f145d96278a64440f3c700f475233b4fd0e7" CACHE STRING "" FORCE) + FetchContent_Declare( + cpptrace + GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git + GIT_TAG v1.0.4 + ) + FetchContent_MakeAvailable(cpptrace) +else() + find_package(cpptrace REQUIRED) +endif() +target_link_libraries(bout++ PUBLIC cpptrace::cpptrace) diff --git a/cmake_build_defines.hxx.in b/cmake_build_defines.hxx.in index 4d63a01b7d..9c73679f29 100644 --- a/cmake_build_defines.hxx.in +++ b/cmake_build_defines.hxx.in @@ -21,7 +21,6 @@ #cmakedefine01 BOUT_HAS_SLEPC #cmakedefine01 BOUT_HAS_SUNDIALS #cmakedefine01 BOUT_HAS_UUID_SYSTEM_GENERATOR -#cmakedefine01 BOUT_USE_BACKTRACE #cmakedefine01 BOUT_USE_COLOR #cmakedefine01 BOUT_USE_OPENMP #cmakedefine01 BOUT_USE_OUTPUT_DEBUG @@ -39,4 +38,7 @@ // CMake build does not support legacy interface #define BOUT_HAS_LEGACY_NETCDF 0 +// We now always turn this on +#define BOUT_USE_BACKTRACE 1 + #endif // BOUT_BUILD_CONFIG_HXX diff --git a/include/bout/boutexception.hxx b/include/bout/boutexception.hxx index ffd4a03a6c..3d8a9cd71d 100644 --- a/include/bout/boutexception.hxx +++ b/include/bout/boutexception.hxx @@ -1,9 +1,6 @@ #ifndef BOUT_EXCEPTION_H #define BOUT_EXCEPTION_H -#include "bout/build_defines.hxx" - -#include #include #include #include @@ -37,12 +34,6 @@ public: private: std::string message; -#if BOUT_USE_BACKTRACE - static constexpr unsigned int TRACE_MAX = 128; - std::array trace{}; - int trace_size; - char** messages; -#endif }; class BoutRhsFail : public BoutException { diff --git a/include/bout/physicsmodel.hxx b/include/bout/physicsmodel.hxx index 9fa25d8b0f..baa284c862 100644 --- a/include/bout/physicsmodel.hxx +++ b/include/bout/physicsmodel.hxx @@ -433,8 +433,7 @@ private: solver->addMonitor(bout_monitor.get(), Solver::BACK); \ solver->solve(); \ } catch (const BoutException& e) { \ - output << "Error encountered: " << e.what(); \ - output << e.getBacktrace() << endl; \ + output.write("Error encountered: {}\n", e.what()); \ MPI_Abort(BoutComm::get(), 1); \ } \ BoutFinalise(); \ diff --git a/manual/doxygen/Doxyfile b/manual/doxygen/Doxyfile index e7998854b0..e2fef90a8c 100644 --- a/manual/doxygen/Doxyfile +++ b/manual/doxygen/Doxyfile @@ -2065,7 +2065,6 @@ PREDEFINED = BACKTRACE \ BOUT_HAS_SLEPC \ BOUT_HAS_SUNDIALS \ BOUT_HAS_UUID_SYSTEM_GENERATOR \ - BOUT_USE_BACKTRACE \ BOUT_USE_COLOR \ BOUT_USE_OPENMP \ BOUT_USE_OUTPUT_DEBUG \ diff --git a/manual/doxygen/Doxyfile_readthedocs b/manual/doxygen/Doxyfile_readthedocs index 73060bb6b4..94113490d9 100644 --- a/manual/doxygen/Doxyfile_readthedocs +++ b/manual/doxygen/Doxyfile_readthedocs @@ -1025,7 +1025,6 @@ PREDEFINED = BACKTRACE \ BOUT_HAS_SLEPC \ BOUT_HAS_SUNDIALS \ BOUT_HAS_UUID_SYSTEM_GENERATOR \ - BOUT_USE_BACKTRACE \ BOUT_USE_COLOR \ BOUT_USE_OPENMP \ BOUT_USE_OUTPUT_DEBUG \ diff --git a/src/sys/boutexception.cxx b/src/sys/boutexception.cxx index e81e395bf8..edf7509077 100644 --- a/src/sys/boutexception.cxx +++ b/src/sys/boutexception.cxx @@ -1,5 +1,3 @@ -#include "bout/build_defines.hxx" - #include #include #include @@ -7,13 +5,10 @@ #include -#if BOUT_USE_BACKTRACE -#include -#include -#include -#endif +#include // IWYU pragma: keep +#include +#include -#include #include #include #include @@ -33,16 +28,10 @@ void BoutParallelThrowRhsFail(int status, const char* message) { } } -BoutException::BoutException(std::string msg) - : message(std::move(msg)) -#if BOUT_USE_BACKTRACE - , - trace_size(backtrace(trace.data(), TRACE_MAX)), - messages(backtrace_symbols(trace.data(), trace_size)) -#endif -{ - if (std::getenv("BOUT_SHOW_BACKTRACE") != nullptr) { - message = fmt::format("{}\n{}", getBacktrace(), message); +BoutException::BoutException(std::string msg) : message(std::move(msg)) { + const char* show_backtrace = std::getenv("BOUT_SHOW_BACKTRACE"); + if (show_backtrace == nullptr or std::string{show_backtrace} != "0") { + message = getBacktrace(); } } @@ -51,62 +40,27 @@ BoutException::~BoutException() { // up the msg_stack. We also won't know how many messages to pop, so // just clear everything msg_stack.clear(); -#if BOUT_USE_BACKTRACE - // Call required for memory allocated by `backtrace_symbols` - free(messages); // NOLINT -#endif } std::string BoutException::getBacktrace() const { - std::string backtrace_message; -#if BOUT_USE_BACKTRACE - backtrace_message = "====== Exception path ======\n"; - // skip first stack frame (points here) - for (int i = trace_size - 1; i > 1; --i) { - backtrace_message = fmt::format(FMT_STRING("{}[bt] #{:d} {:s}\n"), backtrace_message, - i - 1, messages[i]); - // find first occurence of '(' or ' ' in message[i] and assume - // everything before that is the file name. (Don't go beyond 0 though - // (string terminator) - int p = 0; // snprintf %.*s expects int - while (messages[i][p] != '(' && messages[i][p] != ' ' && messages[i][p] != 0) { - ++p; - } + using namespace cpptrace; - // If we are compiled as PIE, need to get base pointer of .so and substract - Dl_info info; - const void* ptr = trace[i]; - if (dladdr(ptr, &info) != 0) { - // Additionally, check whether this is the default offset for an executable - if (info.dli_fbase != reinterpret_cast(0x400000)) { - ptr = reinterpret_cast(reinterpret_cast(ptr) - - reinterpret_cast(info.dli_fbase)); - } - } + const auto colours = isatty(stdout_fileno) || isatty(stderr_fileno) + ? formatter::color_mode::always + : formatter ::color_mode::none; - // Pipe stderr to /dev/null to avoid cluttering output - // when addr2line fails or is not installed - const auto syscom = fmt::format( - FMT_STRING("addr2line {:p} -Cfpie {:.{}s} 2> /dev/null"), ptr, messages[i], p); - // last parameter is the file name of the symbol - FILE* file = popen(syscom.c_str(), "r"); - if (file != nullptr) { - std::array out{}; - const char* retstr = nullptr; - std::string buf; - while ((retstr = fgets(out.data(), out.size() - 1, file)) != nullptr) { - buf += retstr; - } - int const status = pclose(file); - if (status == 0) { - backtrace_message = fmt::format("{}{}", backtrace_message, buf); - } - } - } -#else - backtrace_message = "Stacktrace not enabled.\n"; -#endif + auto formatter = cpptrace::formatter{} + .addresses(formatter::address_mode::none) + .break_before_filename(true) + .colors(colours) + .snippets(true) + .filter([](const stacktrace_frame& frame) { + return frame.symbol.find("BoutException::") == std::string::npos; + }) + .filtered_frame_placeholders(false); + + const std::string backtrace_message = formatter.format(generate_trace()); - return fmt::format("{}{}\n{}{}\n", backtrace_message, msg_stack.getDump(), header, + return fmt::format("{}\n{}\n{}{}\n", backtrace_message, msg_stack.getDump(), header, message); } diff --git a/tests/integrated/test-backtrace/CMakeLists.txt b/tests/integrated/test-backtrace/CMakeLists.txt index b20262f1b1..579f4863ac 100644 --- a/tests/integrated/test-backtrace/CMakeLists.txt +++ b/tests/integrated/test-backtrace/CMakeLists.txt @@ -1,6 +1,4 @@ bout_add_integrated_test(test-backtrace SOURCES boutexcept.cxx - REQUIRES BOUT_USE_BACKTRACE - CONFLICTS CMAKE_SYSTEM_NAME MATCHES "FreeBSD" USE_RUNTEST - ) +) diff --git a/tests/integrated/test-backtrace/runtest b/tests/integrated/test-backtrace/runtest index b41506175e..4010873b56 100755 --- a/tests/integrated/test-backtrace/runtest +++ b/tests/integrated/test-backtrace/runtest @@ -17,13 +17,13 @@ except KeyError: success = True errors = [] -_, output = shell("./boutexcept", pipe=True) +_, output = shell("BOUT_SHOW_BACKTRACE=0 ./boutexcept", pipe=True) if "troublemaker" in output: success = False print("Fail: detected offending function name in output when not expected") -_, output = shell("BOUT_SHOW_BACKTRACE=yes ./boutexcept", pipe=True) +_, output = shell("./boutexcept", pipe=True) if "troublemaker" not in output: success = False diff --git a/tests/unit/sys/test_boutexception.cxx b/tests/unit/sys/test_boutexception.cxx index 322c7d6e42..5eb2c4d719 100644 --- a/tests/unit/sys/test_boutexception.cxx +++ b/tests/unit/sys/test_boutexception.cxx @@ -1,5 +1,3 @@ -#include "bout/build_defines.hxx" - #include "test_extras.hxx" #include "bout/boutexception.hxx" #include "gtest/gtest.h" @@ -7,7 +5,6 @@ #include #include -#include #include TEST(BoutExceptionTest, ThrowCorrect) { @@ -19,13 +16,13 @@ TEST(BoutExceptionTest, What) { try { throw BoutException(test_message); } catch (const BoutException& e) { - EXPECT_EQ(e.what(), test_message); + EXPECT_TRUE(IsSubString(e.what(), test_message)); } try { throw BoutException("this is {}", "second"); } catch (const BoutException& e) { std::string message(e.what()); - EXPECT_EQ(message, "this is second"); + EXPECT_TRUE(IsSubString(message, "this is second")); } } @@ -34,25 +31,19 @@ TEST(BoutExceptionTest, GetBacktrace) { try { throw BoutException(test_message); } catch (const BoutException& e) { - std::string expected_1{"[bt] #1"}; - std::string expected_2{"serial_tests"}; -#if BOUT_USE_BACKTRACE + std::string expected_1{"#2"}; + std::string expected_2{"bout_test_main"}; // Should be able to find something about backtrace - EXPECT_TRUE(IsSubString(e.getBacktrace(), expected_1)); - EXPECT_TRUE(IsSubString(e.getBacktrace(), expected_2)); -#else - // Should *not* be able to find something about backtrace - EXPECT_FALSE(IsSubString(e.getBacktrace(), expected_1)); - EXPECT_FALSE(IsSubString(e.getBacktrace(), expected_2)); -#endif + EXPECT_TRUE(IsSubString(e.what(), expected_1)); + EXPECT_TRUE(IsSubString(e.what(), expected_2)); } } TEST(BoutExceptionTest, FmtJoin) { const std::vector things = {1, 2, 3, 4}; - constexpr std::string_view expected = "list: 1, 2, 3, 4"; + const std::string expected = "list: 1, 2, 3, 4"; const BoutException exception{"list: {}", fmt::join(things, ", ")}; - EXPECT_EQ(exception.what(), expected); + EXPECT_TRUE(IsSubString(std::string{exception.what()}, expected)); } TEST(BoutRhsFailTest, ThrowCorrect) { From 199ba5ae60a58c63722a81b8e0a51bdf0abdfbbd Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 5 Dec 2025 14:35:13 +0000 Subject: [PATCH 02/34] Add some control over `BoutException` backtraces Always generating the backtraces can slow the unit tests down by a factor x2-3 An alternative might be to store the `cpptrace:stacktrace` and only convert to string in `BoutException::what()` --- include/bout/boutexception.hxx | 5 +++++ src/sys/boutexception.cxx | 11 +++++++++-- tests/unit/bout_test_main.cxx | 5 +++++ tests/unit/sys/test_boutexception.cxx | 14 ++++++++++---- tests/unit/test_extras.cxx | 3 ++- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/include/bout/boutexception.hxx b/include/bout/boutexception.hxx index 3d8a9cd71d..565eb6b46d 100644 --- a/include/bout/boutexception.hxx +++ b/include/bout/boutexception.hxx @@ -32,8 +32,13 @@ public: /// backtrace (if available) std::string getBacktrace() const; + static void enableBacktrace() { show_backtrace = true; } + static void disableBacktrace() { show_backtrace = false; } + private: std::string message; + + static bool show_backtrace; }; class BoutRhsFail : public BoutException { diff --git a/src/sys/boutexception.cxx b/src/sys/boutexception.cxx index edf7509077..f08679de83 100644 --- a/src/sys/boutexception.cxx +++ b/src/sys/boutexception.cxx @@ -19,6 +19,8 @@ namespace { const std::string header{"====== Exception thrown ======\n"}; } +bool BoutException::show_backtrace = true; + void BoutParallelThrowRhsFail(int status, const char* message) { int allstatus = 0; MPI_Allreduce(&status, &allstatus, 1, MPI_INT, MPI_LOR, BoutComm::get()); @@ -29,8 +31,13 @@ void BoutParallelThrowRhsFail(int status, const char* message) { } BoutException::BoutException(std::string msg) : message(std::move(msg)) { - const char* show_backtrace = std::getenv("BOUT_SHOW_BACKTRACE"); - if (show_backtrace == nullptr or std::string{show_backtrace} != "0") { + const char* show_backtrace_env_var = std::getenv("BOUT_SHOW_BACKTRACE"); + const auto should_show_backtrace = + show_backtrace + and ((show_backtrace_env_var == nullptr) + or (show_backtrace_env_var != nullptr + and std::string{show_backtrace_env_var} != "0")); + if (should_show_backtrace) { message = getBacktrace(); } } diff --git a/tests/unit/bout_test_main.cxx b/tests/unit/bout_test_main.cxx index 999b5b0dc3..09aeeed0ea 100644 --- a/tests/unit/bout_test_main.cxx +++ b/tests/unit/bout_test_main.cxx @@ -1,6 +1,7 @@ #include #include "bout/array.hxx" +#include "bout/boutexception.hxx" #include "bout/fft.hxx" #include "bout/globalindexer.hxx" #include "bout/output.hxx" @@ -22,6 +23,10 @@ GTEST_API_ int main(int argc, char** argv) { printf("Running main() from bout_test_main.cxx\n"); testing::InitGoogleTest(&argc, argv); + // We throw and catch a bunch of exceptions as part of running the tests, and + // the backtrace generation can _significantly_ slow them down + BoutException::disableBacktrace(); + // Explicitly setup and teardown PETSc to avoid reentry problems // with certain MPI implementations (see #1916 for details) output.disable(); diff --git a/tests/unit/sys/test_boutexception.cxx b/tests/unit/sys/test_boutexception.cxx index 5eb2c4d719..1ba12ef943 100644 --- a/tests/unit/sys/test_boutexception.cxx +++ b/tests/unit/sys/test_boutexception.cxx @@ -7,11 +7,17 @@ #include #include -TEST(BoutExceptionTest, ThrowCorrect) { +// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) +struct BoutExceptionTest : public ::testing::Test { + BoutExceptionTest() { BoutException::enableBacktrace(); } + ~BoutExceptionTest() override { BoutException::disableBacktrace(); } +}; + +TEST_F(BoutExceptionTest, ThrowCorrect) { EXPECT_THROW(throw BoutException("test"), BoutException); } -TEST(BoutExceptionTest, What) { +TEST_F(BoutExceptionTest, What) { std::string test_message{"Test message"}; try { throw BoutException(test_message); @@ -26,7 +32,7 @@ TEST(BoutExceptionTest, What) { } } -TEST(BoutExceptionTest, GetBacktrace) { +TEST_F(BoutExceptionTest, GetBacktrace) { std::string test_message{"Test message"}; try { throw BoutException(test_message); @@ -39,7 +45,7 @@ TEST(BoutExceptionTest, GetBacktrace) { } } -TEST(BoutExceptionTest, FmtJoin) { +TEST_F(BoutExceptionTest, FmtJoin) { const std::vector things = {1, 2, 3, 4}; const std::string expected = "list: 1, 2, 3, 4"; const BoutException exception{"list: {}", fmt::join(things, ", ")}; diff --git a/tests/unit/test_extras.cxx b/tests/unit/test_extras.cxx index 332a53089b..b1caf038d3 100644 --- a/tests/unit/test_extras.cxx +++ b/tests/unit/test_extras.cxx @@ -14,7 +14,8 @@ ::testing::AssertionResult IsSubString(const std::string& str, if (str.find(substring) != std::string::npos) { return ::testing::AssertionSuccess(); } else { - return ::testing::AssertionFailure() << '"' << substring << "\" not found in " << str; + return ::testing::AssertionFailure() + << '"' << substring << "\" not found in \"" << str << '"'; } } From dc865d338a9b62f2406375410426723dc009147c Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 5 Dec 2025 15:01:05 +0000 Subject: [PATCH 03/34] Try to ensure `build_defines` is included where it's used --- include/bout/coordinates.hxx | 9 +++++---- include/bout/fv_ops.hxx | 4 ++-- include/bout/interpolation_xz.hxx | 1 + include/bout/output.hxx | 3 ++- src/invert/laplace/invert_laplace.cxx | 1 + src/mesh/boundary_standard.cxx | 1 + src/mesh/coordinates.cxx | 1 + src/mesh/coordinates_accessor.cxx | 1 + src/sys/derivs.cxx | 1 + tests/unit/field/test_vector2d.cxx | 6 ++++-- tests/unit/include/bout/test_single_index_ops.cxx | 1 + tests/unit/mesh/data/test_gridfromoptions.cxx | 2 +- tests/unit/solver/test_solver.cxx | 1 + tests/unit/sys/test_output.cxx | 4 ++-- 14 files changed, 24 insertions(+), 12 deletions(-) diff --git a/include/bout/coordinates.hxx b/include/bout/coordinates.hxx index d7c80ed8bc..e7ead42ee5 100644 --- a/include/bout/coordinates.hxx +++ b/include/bout/coordinates.hxx @@ -33,10 +33,11 @@ #ifndef BOUT_COORDINATES_H #define BOUT_COORDINATES_H -#include "bout/bout_types.hxx" -#include "bout/field2d.hxx" -#include "bout/field3d.hxx" -#include "bout/paralleltransform.hxx" +#include +#include +#include +#include +#include class Mesh; diff --git a/include/bout/fv_ops.hxx b/include/bout/fv_ops.hxx index 94007a57a2..ce98e03008 100644 --- a/include/bout/fv_ops.hxx +++ b/include/bout/fv_ops.hxx @@ -5,11 +5,11 @@ #ifndef BOUT_FV_OPS_H #define BOUT_FV_OPS_H +#include "bout/build_defines.hxx" #include "bout/field3d.hxx" #include "bout/globals.hxx" -#include "bout/vector2d.hxx" - #include "bout/utils.hxx" +#include "bout/vector2d.hxx" #include namespace FV { diff --git a/include/bout/interpolation_xz.hxx b/include/bout/interpolation_xz.hxx index 6c7419f7e4..79e959b3af 100644 --- a/include/bout/interpolation_xz.hxx +++ b/include/bout/interpolation_xz.hxx @@ -24,6 +24,7 @@ #ifndef BOUT_INTERP_XZ_H #define BOUT_INTERP_XZ_H +#include "bout/build_defines.hxx" #include "bout/mask.hxx" #define USE_NEW_WEIGHTS 1 diff --git a/include/bout/output.hxx b/include/bout/output.hxx index 823e359753..34b4f19376 100644 --- a/include/bout/output.hxx +++ b/include/bout/output.hxx @@ -29,12 +29,13 @@ class Output; #ifndef BOUT_OUTPUT_H #define BOUT_OUTPUT_H -#include "bout/multiostream.hxx" #include #include #include #include "bout/assert.hxx" +#include "bout/build_defines.hxx" +#include "bout/multiostream.hxx" #include "bout/sys/gettext.hxx" // IWYU pragma: keep for gettext _() macro #include "bout/unused.hxx" diff --git a/src/invert/laplace/invert_laplace.cxx b/src/invert/laplace/invert_laplace.cxx index 4032499781..7a8af20fbd 100644 --- a/src/invert/laplace/invert_laplace.cxx +++ b/src/invert/laplace/invert_laplace.cxx @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/src/mesh/boundary_standard.cxx b/src/mesh/boundary_standard.cxx index 8f2c7df5ec..5508f8db71 100644 --- a/src/mesh/boundary_standard.cxx +++ b/src/mesh/boundary_standard.cxx @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/src/mesh/coordinates.cxx b/src/mesh/coordinates.cxx index 3dfee6a553..58d54f826e 100644 --- a/src/mesh/coordinates.cxx +++ b/src/mesh/coordinates.cxx @@ -5,6 +5,7 @@ **************************************************************************/ #include +#include #include #include #include diff --git a/src/mesh/coordinates_accessor.cxx b/src/mesh/coordinates_accessor.cxx index aff546c2b0..0ce4b664b5 100644 --- a/src/mesh/coordinates_accessor.cxx +++ b/src/mesh/coordinates_accessor.cxx @@ -1,4 +1,5 @@ #include "bout/coordinates_accessor.hxx" +#include #include "bout/mesh.hxx" diff --git a/src/sys/derivs.cxx b/src/sys/derivs.cxx index ee9bcbcc2c..ed036fffd4 100644 --- a/src/sys/derivs.cxx +++ b/src/sys/derivs.cxx @@ -38,6 +38,7 @@ * **************************************************************************/ +#include #include #include #include diff --git a/tests/unit/field/test_vector2d.cxx b/tests/unit/field/test_vector2d.cxx index df438c3dbf..de662c7df8 100644 --- a/tests/unit/field/test_vector2d.cxx +++ b/tests/unit/field/test_vector2d.cxx @@ -1,8 +1,8 @@ -#include "gtest/gtest.h" +#include -#include "bout/boutexception.hxx" #if not(BOUT_USE_METRIC_3D) #include "test_extras.hxx" +#include "bout/boutexception.hxx" #include "bout/mesh.hxx" #include "bout/mpi_wrapper.hxx" #include "bout/output.hxx" @@ -11,6 +11,8 @@ #include "fake_mesh.hxx" +#include "gtest/gtest.h" + // The unit tests use the global mesh using namespace bout::globals; diff --git a/tests/unit/include/bout/test_single_index_ops.cxx b/tests/unit/include/bout/test_single_index_ops.cxx index 4359d1d282..a809ae3683 100644 --- a/tests/unit/include/bout/test_single_index_ops.cxx +++ b/tests/unit/include/bout/test_single_index_ops.cxx @@ -2,6 +2,7 @@ #include "test_extras.hxx" +#include "bout/build_defines.hxx" #include "bout/derivs.hxx" #include "bout/difops.hxx" #include "bout/single_index_ops.hxx" diff --git a/tests/unit/mesh/data/test_gridfromoptions.cxx b/tests/unit/mesh/data/test_gridfromoptions.cxx index 8d3dbfebdf..b821d2e225 100644 --- a/tests/unit/mesh/data/test_gridfromoptions.cxx +++ b/tests/unit/mesh/data/test_gridfromoptions.cxx @@ -1,13 +1,13 @@ #include "gtest/gtest.h" #include "test_extras.hxx" +#include "bout/build_defines.hxx" #include "bout/constants.hxx" #include "bout/griddata.hxx" #include "bout/mesh.hxx" #include "bout/options.hxx" #include "bout/output.hxx" -#include #include #include diff --git a/tests/unit/solver/test_solver.cxx b/tests/unit/solver/test_solver.cxx index 2e29fd90bc..e9a612103c 100644 --- a/tests/unit/solver/test_solver.cxx +++ b/tests/unit/solver/test_solver.cxx @@ -4,6 +4,7 @@ #include "test_extras.hxx" #include "test_fakesolver.hxx" #include "bout/boutexception.hxx" +#include "bout/build_defines.hxx" #include "bout/field2d.hxx" #include "bout/field3d.hxx" #include "bout/physicsmodel.hxx" diff --git a/tests/unit/sys/test_output.cxx b/tests/unit/sys/test_output.cxx index 959823ede3..2f13df9cb7 100644 --- a/tests/unit/sys/test_output.cxx +++ b/tests/unit/sys/test_output.cxx @@ -1,7 +1,7 @@ #include "test_tmpfiles.hxx" -#include "bout/boutexception.hxx" +#include "bout/build_defines.hxx" #include "bout/output.hxx" -#include "bout/output_bout_types.hxx" +#include "bout/output_bout_types.hxx" // IWYU pragma: keep #include "gtest/gtest.h" #include From e0710f8b88ad3ed4cdfadb731e446cd4dcaac75d Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Tue, 16 Dec 2025 15:43:49 +0000 Subject: [PATCH 04/34] Try to make backtrace unit test more portable --- tests/unit/sys/test_boutexception.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/sys/test_boutexception.cxx b/tests/unit/sys/test_boutexception.cxx index 1ba12ef943..7cde2f57a1 100644 --- a/tests/unit/sys/test_boutexception.cxx +++ b/tests/unit/sys/test_boutexception.cxx @@ -37,11 +37,11 @@ TEST_F(BoutExceptionTest, GetBacktrace) { try { throw BoutException(test_message); } catch (const BoutException& e) { - std::string expected_1{"#2"}; - std::string expected_2{"bout_test_main"}; // Should be able to find something about backtrace - EXPECT_TRUE(IsSubString(e.what(), expected_1)); - EXPECT_TRUE(IsSubString(e.what(), expected_2)); + EXPECT_TRUE(IsSubString(e.what(), "#2")); + // We should be able to see either the main source file or the executable name + EXPECT_TRUE(IsSubString(e.what(), "bout_test_main") + || IsSubString(e.what(), "serial_tests")); } } From 9dd86c53443c8a6253cebab4fbff65bbf03ecebd Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 11:52:10 +0000 Subject: [PATCH 05/34] cmake: Fix some issues with building with cpptrace - Add paths to `FetchContent` dirs in config file - Switch to custom versions of cpptrace/libdward-lite - Includes some cmake fixes in both projects --- bout++Config.cmake.in | 3 +++ cmake/SetupBOUTThirdParty.cmake | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bout++Config.cmake.in b/bout++Config.cmake.in index a82479f41c..a8cf041901 100644 --- a/bout++Config.cmake.in +++ b/bout++Config.cmake.in @@ -112,6 +112,9 @@ if(EXISTS "@cpptrace_ROOT@") set(cpptrace_ROOT "@cpptrace_ROOT@") elseif(EXISTS "@cpptrace_BINARY_DIR@") list(APPEND CMAKE_PREFIX_PATH "@cpptrace_BINARY_DIR@") + list(APPEND CMAKE_PREFIX_PATH "@cpptrace_BINARY_DIR@/cmake") + list(APPEND CMAKE_PREFIX_PATH "@libdwarf_BINARY_DIR@/src/lib/libdwarf") + list(APPEND CMAKE_PREFIX_PATH "@zstd_BINARY_DIR@") endif() if(@BOUT_USE_SYSTEM_MPARK_VARIANT@) diff --git a/cmake/SetupBOUTThirdParty.cmake b/cmake/SetupBOUTThirdParty.cmake index 2249fb3468..2c5b9a1cfb 100644 --- a/cmake/SetupBOUTThirdParty.cmake +++ b/cmake/SetupBOUTThirdParty.cmake @@ -374,11 +374,11 @@ option(BOUT_DOWNLOAD_CPPTRACE "Download cpptrace for backtrace support" ON) if (BOUT_DOWNLOAD_CPPTRACE) include(FetchContent) set(CPPTRACE_LIBDWARF_REPO "https://github.com/ZedThree/libdwarf-lite.git" CACHE STRING "" FORCE) - set(CPPTRACE_LIBDWARF_TAG "5f15f145d96278a64440f3c700f475233b4fd0e7" CACHE STRING "" FORCE) + set(CPPTRACE_LIBDWARF_TAG "ebe10a39afd56b8247de633bfe17666ad50ab95e" CACHE STRING "" FORCE) FetchContent_Declare( cpptrace - GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git - GIT_TAG v1.0.4 + GIT_REPOSITORY https://github.com/ZedThree/cpptrace.git + GIT_TAG "027f9aee2d34dbe1c98f26224e1fbe1654cb4aae" ) FetchContent_MakeAvailable(cpptrace) else() From 00995ea544670a409f584015ab4e07485683b86b Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 12:03:50 +0000 Subject: [PATCH 06/34] Prettify symbols in cpptrace output --- src/sys/boutexception.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sys/boutexception.cxx b/src/sys/boutexception.cxx index f08679de83..5bcec420f3 100644 --- a/src/sys/boutexception.cxx +++ b/src/sys/boutexception.cxx @@ -54,13 +54,14 @@ std::string BoutException::getBacktrace() const { const auto colours = isatty(stdout_fileno) || isatty(stderr_fileno) ? formatter::color_mode::always - : formatter ::color_mode::none; + : formatter::color_mode::none; auto formatter = cpptrace::formatter{} .addresses(formatter::address_mode::none) .break_before_filename(true) .colors(colours) .snippets(true) + .symbols(formatter::symbol_mode::pretty) .filter([](const stacktrace_frame& frame) { return frame.symbol.find("BoutException::") == std::string::npos; }) From 3fc530d5c45e719546c929a831d1f6daf8eabbce Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 12:11:03 +0000 Subject: [PATCH 07/34] Filter out pre-main functions from stacktrace --- src/sys/boutexception.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sys/boutexception.cxx b/src/sys/boutexception.cxx index 5bcec420f3..c91bb186bf 100644 --- a/src/sys/boutexception.cxx +++ b/src/sys/boutexception.cxx @@ -63,7 +63,12 @@ std::string BoutException::getBacktrace() const { .snippets(true) .symbols(formatter::symbol_mode::pretty) .filter([](const stacktrace_frame& frame) { - return frame.symbol.find("BoutException::") == std::string::npos; + return ( + // Don't include our exception machinery + (frame.symbol.find("BoutException::") == std::string::npos) + // Don't include pre-main functions + and (frame.symbol.find("__libc_start") == std::string::npos) + and (frame.symbol != "_start")); }) .filtered_frame_placeholders(false); From 5f77485d249c17f76b453ee7fe4cb08aea423cdb Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 12:12:48 +0000 Subject: [PATCH 08/34] Include filtered placeholders --- src/sys/boutexception.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sys/boutexception.cxx b/src/sys/boutexception.cxx index c91bb186bf..8509dc40ba 100644 --- a/src/sys/boutexception.cxx +++ b/src/sys/boutexception.cxx @@ -69,8 +69,7 @@ std::string BoutException::getBacktrace() const { // Don't include pre-main functions and (frame.symbol.find("__libc_start") == std::string::npos) and (frame.symbol != "_start")); - }) - .filtered_frame_placeholders(false); + }); const std::string backtrace_message = formatter.format(generate_trace()); From cbc4cf20bb3effb66a1656a9fea9424a5e228350 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 15:53:29 +0000 Subject: [PATCH 09/34] Remove `AUTO_TRACE` macro --- include/bout/bout_enum_class.hxx | 4 +- include/bout/deriv_store.hxx | 39 +++++++------------ include/bout/field.hxx | 11 +----- include/bout/hypre_interface.hxx | 6 +-- include/bout/index_derivs.hxx | 6 +-- include/bout/index_derivs_interface.hxx | 31 +++++++-------- include/bout/interpolation.hxx | 2 +- include/bout/invertable_operator.hxx | 13 +++---- include/bout/mesh.hxx | 6 +-- include/bout/msg_stack.hxx | 31 --------------- include/bout/petsc_interface.hxx | 6 +-- include/bout/scorepwrapper.hxx | 13 ++++++- include/bout/sys/timer.hxx | 1 - manual/doxygen/Doxyfile | 1 - manual/doxygen/Doxyfile_readthedocs | 1 - manual/sphinx/developer_docs/debugging.rst | 14 ++----- src/bout++.cxx | 3 -- src/field/field_data.cxx | 7 +--- src/field/field_factory.cxx | 3 -- src/field/initialprofiles.cxx | 4 -- src/field/vecops.cxx | 4 +- .../laplace/impls/petsc3damg/petsc3damg.cxx | 1 - src/mesh/data/gridfromfile.cxx | 1 - src/mesh/index_derivs.cxx | 12 +++--- src/mesh/parallel/shiftedmetricinterp.cxx | 1 - src/physics/smoothing.cxx | 2 +- .../impls/adams_bashforth/adams_bashforth.cxx | 31 +++++++-------- src/solver/impls/split-rk/split-rk.cxx | 2 - src/solver/solver.cxx | 4 +- src/sys/bout_types.cxx | 26 ++++++------- src/sys/msg_stack.cxx | 2 +- .../integrated/test-backtrace/boutexcept.cxx | 15 ++----- 32 files changed, 107 insertions(+), 196 deletions(-) diff --git a/include/bout/bout_enum_class.hxx b/include/bout/bout_enum_class.hxx index 585e5b020e..07140220a4 100644 --- a/include/bout/bout_enum_class.hxx +++ b/include/bout/bout_enum_class.hxx @@ -70,7 +70,7 @@ enum class enumname { __VA_ARGS__ }; \ \ inline std::string toString(enumname e) { \ - AUTO_TRACE(); \ + \ const static std::map toString_map = { \ BOUT_ENUM_CLASS_MAP_ARGS(BOUT_ENUM_CLASS_STR, enumname, __VA_ARGS__)}; \ auto found = toString_map.find(e); \ @@ -81,7 +81,7 @@ } \ \ inline enumname BOUT_MAKE_FROMSTRING_NAME(enumname)(const std::string& s) { \ - AUTO_TRACE(); \ + \ const static std::map fromString_map = { \ BOUT_ENUM_CLASS_MAP_ARGS(BOUT_STR_ENUM_CLASS, enumname, __VA_ARGS__)}; \ auto found = fromString_map.find(s); \ diff --git a/include/bout/deriv_store.hxx b/include/bout/deriv_store.hxx index 6dc44c76ad..866ac558e5 100644 --- a/include/bout/deriv_store.hxx +++ b/include/bout/deriv_store.hxx @@ -75,21 +75,14 @@ struct DerivativeStore { } /// Report if store has any registered methods - bool isEmpty() const { - AUTO_TRACE(); - return registeredMethods.empty(); - }; + bool isEmpty() const { return registeredMethods.empty(); }; /// Report if store has any registered methods for specific type determined by key - bool isEmpty(std::size_t key) const { - AUTO_TRACE(); - return registeredMethods.count(key) == 0; - } + bool isEmpty(std::size_t key) const { return registeredMethods.count(key) == 0; } /// Report if store has any registered methods for specific type bool isEmpty(DERIV derivType, DIRECTION direction, STAGGER stagger = STAGGER::None) const { - AUTO_TRACE(); // Get the key auto key = getKey(direction, stagger, toString(derivType)); @@ -100,7 +93,6 @@ struct DerivativeStore { /// specified derivative type, direction and stagger. std::set getAvailableMethods(DERIV derivType, DIRECTION direction, STAGGER stagger = STAGGER::None) const { - AUTO_TRACE(); // Get the key auto key = getKey(direction, stagger, toString(derivType)); @@ -115,7 +107,6 @@ struct DerivativeStore { /// specified derivative type, direction and stagger. void listAvailableMethods(DERIV derivType, DIRECTION direction, STAGGER stagger = STAGGER::None) const { - AUTO_TRACE(); // Introductory information output_info << "Available methods for derivative type '"; @@ -134,7 +125,7 @@ struct DerivativeStore { /// depends on the derivType input. void registerDerivative(standardFunc func, DERIV derivType, DIRECTION direction, STAGGER stagger, std::string methodName) { - AUTO_TRACE(); + const auto key = getKey(direction, stagger, methodName); switch (derivType) { @@ -176,7 +167,7 @@ struct DerivativeStore { /// depends on the derivType input. void registerDerivative(upwindFunc func, DERIV derivType, DIRECTION direction, STAGGER stagger, std::string methodName) { - AUTO_TRACE(); + const auto key = getKey(direction, stagger, methodName); switch (derivType) { @@ -210,14 +201,14 @@ struct DerivativeStore { template void registerDerivative(standardFunc func, Direction direction, Stagger stagger, Method method) { - AUTO_TRACE(); + registerDerivative(func, method.meta.derivType, direction.lookup(), stagger.lookup(), method.meta.key); } template void registerDerivative(upwindFunc func, Direction direction, Stagger stagger, Method method) { - AUTO_TRACE(); + registerDerivative(func, method.meta.derivType, direction.lookup(), stagger.lookup(), method.meta.key); } @@ -231,7 +222,6 @@ struct DerivativeStore { STAGGER stagger = STAGGER::None, DERIV derivType = DERIV::Standard) const { - AUTO_TRACE(); const auto realName = nameLookup( name, defaultMethods.at(getKey(direction, stagger, toString(derivType)))); const auto key = getKey(direction, stagger, realName); @@ -262,20 +252,20 @@ struct DerivativeStore { standardFunc getStandard2ndDerivative(std::string name, DIRECTION direction, STAGGER stagger = STAGGER::None) const { - AUTO_TRACE(); + return getStandardDerivative(name, direction, stagger, DERIV::StandardSecond); }; standardFunc getStandard4thDerivative(std::string name, DIRECTION direction, STAGGER stagger = STAGGER::None) const { - AUTO_TRACE(); + return getStandardDerivative(name, direction, stagger, DERIV::StandardFourth); }; flowFunc getFlowDerivative(std::string name, DIRECTION direction, STAGGER stagger = STAGGER::None, DERIV derivType = DERIV::Upwind) const { - AUTO_TRACE(); + const auto realName = nameLookup( name, defaultMethods.at(getKey(direction, stagger, toString(derivType)))); const auto key = getKey(direction, stagger, realName); @@ -305,18 +295,17 @@ struct DerivativeStore { upwindFunc getUpwindDerivative(std::string name, DIRECTION direction, STAGGER stagger = STAGGER::None) const { - AUTO_TRACE(); + return getFlowDerivative(name, direction, stagger, DERIV::Upwind); }; fluxFunc getFluxDerivative(std::string name, DIRECTION direction, STAGGER stagger = STAGGER::None) const { - AUTO_TRACE(); + return getFlowDerivative(name, direction, stagger, DERIV::Flux); }; void initialise(Options* options) { - AUTO_TRACE(); // To replicate the existing behaviour we first search for a section called //"dd?" and if the option isn't in there we search a section called "diff" @@ -490,7 +479,7 @@ private: std::string getMethodName(std::string name, DIRECTION direction, STAGGER stagger = STAGGER::None) const { - AUTO_TRACE(); + return name + " (" + toString(direction) + ", " + toString(stagger) + ")"; }; @@ -506,7 +495,7 @@ private: /// methods with the same function interface in the same map, which /// might be nice. std::size_t getKey(DIRECTION direction, STAGGER stagger, std::string key) const { - AUTO_TRACE(); + // Note this key is indepedent of the field type (and hence the // key is the same for 3D/2D fields) as we have to use different // maps to store the different field types as the signature is @@ -524,7 +513,7 @@ private: /// that can be used to account for run-time choices template std::size_t getKey() const { - AUTO_TRACE(); + // Note this key is indepedent of the field type (and hence the // key is the same for 3D/2D fields) as we have to use different // maps to store the different field types as the signature is diff --git a/include/bout/field.hxx b/include/bout/field.hxx index 61edff6723..35ce42716d 100644 --- a/include/bout/field.hxx +++ b/include/bout/field.hxx @@ -239,7 +239,6 @@ namespace bout { template inline void checkFinite(const T& f, const std::string& name = "field", const std::string& rgn = "RGN_ALL") { - AUTO_TRACE(); if (!f.isAllocated()) { throw BoutException("{:s} is not allocated", name); @@ -263,7 +262,6 @@ inline void checkFinite(const T& f, const std::string& name = "field", template inline void checkPositive(const T& f, const std::string& name = "field", const std::string& rgn = "RGN_ALL") { - AUTO_TRACE(); if (!f.isAllocated()) { throw BoutException("{:s} is not allocated", name); @@ -307,7 +305,6 @@ inline T fromFieldAligned(const T& f, const std::string& region = "RGN_ALL") { template > inline BoutReal min(const T& f, bool allpe = false, const std::string& rgn = "RGN_NOBNDRY") { - AUTO_TRACE(); checkData(f); @@ -392,7 +389,6 @@ inline BoutReal getUniform(const T& f, [[maybe_unused]] bool allpe = false, template > inline BoutReal max(const T& f, bool allpe = false, const std::string& rgn = "RGN_NOBNDRY") { - AUTO_TRACE(); checkData(f); @@ -426,7 +422,6 @@ inline BoutReal max(const T& f, bool allpe = false, template > inline BoutReal mean(const T& f, bool allpe = false, const std::string& rgn = "RGN_NOBNDRY") { - AUTO_TRACE(); checkData(f); @@ -457,7 +452,6 @@ inline BoutReal mean(const T& f, bool allpe = false, /// If CHECK >= 3 then the result will be checked for non-finite numbers template > T pow(const T& lhs, const T& rhs, const std::string& rgn = "RGN_ALL") { - AUTO_TRACE(); ASSERT1(areFieldsCompatible(lhs, rhs)); @@ -471,7 +465,6 @@ T pow(const T& lhs, const T& rhs, const std::string& rgn = "RGN_ALL") { template > T pow(const T& lhs, BoutReal rhs, const std::string& rgn = "RGN_ALL") { - AUTO_TRACE(); // Check if the inputs are allocated checkData(lhs); @@ -487,7 +480,6 @@ T pow(const T& lhs, BoutReal rhs, const std::string& rgn = "RGN_ALL") { template > T pow(BoutReal lhs, const T& rhs, const std::string& rgn = "RGN_ALL") { - AUTO_TRACE(); // Check if the inputs are allocated checkData(lhs); @@ -524,7 +516,7 @@ T pow(BoutReal lhs, const T& rhs, const std::string& rgn = "RGN_ALL") { #define FIELD_FUNC(name, func) \ template > \ inline T name(const T& f, const std::string& rgn = "RGN_ALL") { \ - AUTO_TRACE(); \ + \ /* Check if the input is allocated */ \ checkData(f); \ /* Define and allocate the output result */ \ @@ -632,7 +624,6 @@ FIELD_FUNC(tanh, ::tanh) /// default (can be changed using the \p rgn argument template > inline bool finite(const T& f, const std::string& rgn = "RGN_ALL") { - AUTO_TRACE(); if (!f.isAllocated()) { return false; diff --git a/include/bout/hypre_interface.hxx b/include/bout/hypre_interface.hxx index ae392de4f3..65d8875a9a 100644 --- a/include/bout/hypre_interface.hxx +++ b/include/bout/hypre_interface.hxx @@ -444,19 +444,19 @@ public: value = matrix->getVal(row, column); } Element& operator=(const Element& other) { - AUTO_TRACE(); + ASSERT3(finite(static_cast(other))); return *this = static_cast(other); } Element& operator=(BoutReal value_) { - AUTO_TRACE(); + ASSERT3(finite(value_)); value = value_; setValues(value); return *this; } Element& operator+=(BoutReal value_) { - AUTO_TRACE(); + ASSERT3(finite(value_)); auto column_position = std::find(cbegin(positions), cend(positions), column); if (column_position != cend(positions)) { diff --git a/include/bout/index_derivs.hxx b/include/bout/index_derivs.hxx index 456f98f8c2..7c2be52ded 100644 --- a/include/bout/index_derivs.hxx +++ b/include/bout/index_derivs.hxx @@ -84,7 +84,7 @@ class DerivativeType { public: template void standard(const T& var, T& result, const std::string& region) const { - AUTO_TRACE(); + ASSERT2(meta.derivType == DERIV::Standard || meta.derivType == DERIV::StandardSecond || meta.derivType == DERIV::StandardFourth) ASSERT2(var.getMesh()->getNguard(direction) >= nGuards); @@ -98,7 +98,7 @@ public: template void upwindOrFlux(const T& vel, const T& var, T& result, const std::string& region) const { - AUTO_TRACE(); + ASSERT2(meta.derivType == DERIV::Upwind || meta.derivType == DERIV::Flux) ASSERT2(var.getMesh()->getNguard(direction) >= nGuards); @@ -133,7 +133,7 @@ struct registerMethod { template void operator()(Direction, Stagger, FieldTypeContainer, Method) { - AUTO_TRACE(); + using namespace std::placeholders; // Now we want to get the actual field type out of the TypeContainer diff --git a/include/bout/index_derivs_interface.hxx b/include/bout/index_derivs_interface.hxx index 8f7e41a68e..242492c3f8 100644 --- a/include/bout/index_derivs_interface.hxx +++ b/include/bout/index_derivs_interface.hxx @@ -45,7 +45,6 @@ namespace index { template T flowDerivative(const T& vel, const T& f, CELL_LOC outloc, const std::string& method, const std::string& region) { - AUTO_TRACE(); // Checks static_assert(bout::utils::is_Field2D_v || bout::utils::is_Field3D_v, @@ -110,7 +109,6 @@ T flowDerivative(const T& vel, const T& f, CELL_LOC outloc, const std::string& m template T standardDerivative(const T& f, CELL_LOC outloc, const std::string& method, const std::string& region) { - AUTO_TRACE(); // Checks static_assert(bout::utils::is_Field2D_v || bout::utils::is_Field3D_v, @@ -174,14 +172,14 @@ T standardDerivative(const T& f, CELL_LOC outloc, const std::string& method, template T DDX(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + return standardDerivative(f, outloc, method, region); } template T D2DX2(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + return standardDerivative(f, outloc, method, region); } @@ -189,7 +187,7 @@ T D2DX2(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = template T D4DX4(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + return standardDerivative(f, outloc, method, region); } @@ -199,7 +197,7 @@ T D4DX4(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = template T DDY(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + if (f.hasParallelSlices()) { ASSERT1(f.getDirectionY() == YDirectionType::Standard); return standardDerivative(f, outloc, @@ -216,7 +214,7 @@ T DDY(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "D template T D2DY2(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + if (f.hasParallelSlices()) { ASSERT1(f.getDirectionY() == YDirectionType::Standard); return standardDerivative( @@ -233,7 +231,7 @@ T D2DY2(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = template T D4DY4(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + if (f.hasParallelSlices()) { ASSERT1(f.getDirectionY() == YDirectionType::Standard); return standardDerivative( @@ -251,14 +249,14 @@ T D4DY4(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = template T DDZ(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + return standardDerivative(f, outloc, method, region); } template T D2DZ2(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + return standardDerivative(f, outloc, method, region); } @@ -266,7 +264,7 @@ T D2DZ2(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = template T D4DZ4(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + return standardDerivative(f, outloc, method, region); } @@ -291,14 +289,14 @@ T D4DZ4(const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = template T VDDX(const T& vel, const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + return flowDerivative(vel, f, outloc, method, region); } template T FDDX(const T& vel, const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + return flowDerivative(vel, f, outloc, method, region); } @@ -307,7 +305,6 @@ T FDDX(const T& vel, const T& f, CELL_LOC outloc = CELL_DEFAULT, template T VDDY(const T& vel, const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); // Note the following chunk is copy+pasted from flowDerivative // above. Not pulled out as a separate function due the number of @@ -363,7 +360,7 @@ T VDDY(const T& vel, const T& f, CELL_LOC outloc = CELL_DEFAULT, template T FDDY(const T& vel, const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + const bool fHasParallelSlices = (f.hasParallelSlices()); const bool velHasParallelSlices = (vel.hasParallelSlices()); if (fHasParallelSlices && velHasParallelSlices) { @@ -389,14 +386,14 @@ T FDDY(const T& vel, const T& f, CELL_LOC outloc = CELL_DEFAULT, template T VDDZ(const T& vel, const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + return flowDerivative(vel, f, outloc, method, region); } template T FDDZ(const T& vel, const T& f, CELL_LOC outloc = CELL_DEFAULT, const std::string& method = "DEFAULT", const std::string& region = "RGN_NOBNDRY") { - AUTO_TRACE(); + return flowDerivative(vel, f, outloc, method, region); } diff --git a/include/bout/interpolation.hxx b/include/bout/interpolation.hxx index 2c7df4472d..1753dfe0c0 100644 --- a/include/bout/interpolation.hxx +++ b/include/bout/interpolation.hxx @@ -56,7 +56,7 @@ inline BoutReal interp(const stencil& s) { */ template const T interp_to(const T& var, CELL_LOC loc, const std::string region = "RGN_ALL") { - AUTO_TRACE(); + static_assert(bout::utils::is_Field2D_v || bout::utils::is_Field3D_v, "interp_to must be templated with one of Field2D or Field3D."); ASSERT1(loc != CELL_DEFAULT); // doesn't make sense to interplote to CELL_DEFAULT diff --git a/include/bout/invertable_operator.hxx b/include/bout/invertable_operator.hxx index 9b9dbba41a..ffc0910dce 100644 --- a/include/bout/invertable_operator.hxx +++ b/include/bout/invertable_operator.hxx @@ -61,7 +61,7 @@ namespace inversion { /// No-op function to use as a default -- may wish to remove once testing phase complete template T identity(const T& in) { - AUTO_TRACE(); + return in; }; @@ -137,8 +137,8 @@ public: opt(optIn == nullptr ? Options::getRoot()->getSection("invertableOperator") : optIn), localmesh(localmeshIn == nullptr ? bout::globals::mesh : localmeshIn), lib(opt) { - AUTO_TRACE(); - }; + + }; /// Destructor just has to cleanup the PETSc owned objects. ~InvertableOperator() { @@ -177,10 +177,7 @@ public: } /// Provide a synonym for applying the operator to a Field - T apply(const T& input) { - AUTO_TRACE(); - return operator()(input); - } + T apply(const T& input) { return operator()(input); } /// Sets up the PETSc objects required for inverting the operator /// Currently also takes the functor that applies the operator this class @@ -386,7 +383,7 @@ public: // but suspect it's not as there are KSPGuess objects // to deal with. T invert(const T& rhsField, const T& guess) { - AUTO_TRACE(); + auto ierr = fieldToPetscVec(guess, lhs); CHKERRQ(ierr); return invert(rhsField); diff --git a/include/bout/mesh.hxx b/include/bout/mesh.hxx index 2e27bed777..0d9471d1d2 100644 --- a/include/bout/mesh.hxx +++ b/include/bout/mesh.hxx @@ -652,7 +652,7 @@ public: /// Returns the non-CELL_CENTRE location /// allowed as a staggered location static CELL_LOC getAllowedStaggerLoc(DIRECTION direction) { - AUTO_TRACE(); + switch (direction) { case (DIRECTION::X): return CELL_XLOW; @@ -670,7 +670,7 @@ public: /// Returns the number of grid points in the /// particular direction int getNpoints(DIRECTION direction) const { - AUTO_TRACE(); + switch (direction) { case (DIRECTION::X): return LocalNx; @@ -688,7 +688,7 @@ public: /// Returns the number of guard points in the /// particular direction int getNguard(DIRECTION direction) const { - AUTO_TRACE(); + switch (direction) { case (DIRECTION::X): return xstart; diff --git a/include/bout/msg_stack.hxx b/include/bout/msg_stack.hxx index 6d19469e25..765a3120cf 100644 --- a/include/bout/msg_stack.hxx +++ b/include/bout/msg_stack.hxx @@ -40,18 +40,6 @@ class MsgStack; #include #include -/// The __PRETTY_FUNCTION__ variable is defined by GCC (and some other families) but is -/// not a part of the standard. The __func__ variable *is* a part of the c++11 standard so -/// we'd like to fall back to this if possible. However as these are variables/constants -/// and not macros we can't just check if __PRETTY_FUNCITON__ is defined or not. Instead -/// we need to say if we support this or not by defining BOUT_HAS_PRETTY_FUNCTION (to be -/// implemented in configure) -#if BOUT_HAS_PRETTY_FUNCTION -#define __thefunc__ __PRETTY_FUNCTION__ -#else -#define __thefunc__ __func__ -#endif - /*! * Message stack * @@ -193,23 +181,4 @@ private: #define TRACE(...) #endif -/*! - * The AUTO_TRACE macro provides a convenient way to put messages onto the msg_stack - * It pushes a message onto the stack, and pops it when the scope ends - * The message is automatically derived from the function signature - * as identified by the compiler. This will be PRETTY_FUNCTION if available - * else it will be the mangled form. - * - * This is implemented as a use of the TRACE macro with specific arguments. - * - * Example - * ------- - * - * { - * AUTO_TRACE(); - * - * } // Scope ends, message popped - */ -#define AUTO_TRACE() TRACE(__thefunc__) // NOLINT - #endif // BOUT_MSG_STACK_H diff --git a/include/bout/petsc_interface.hxx b/include/bout/petsc_interface.hxx index 3ae02f41a6..5edd42a441 100644 --- a/include/bout/petsc_interface.hxx +++ b/include/bout/petsc_interface.hxx @@ -363,7 +363,7 @@ public: } } Element& operator=(const Element& other) { - AUTO_TRACE(); + if (this == &other) { return *this; } @@ -372,14 +372,14 @@ public: return *this; } Element& operator=(BoutReal val) { - AUTO_TRACE(); + ASSERT3(finite(val)); value = val; setValues(val, INSERT_VALUES); return *this; } Element& operator+=(BoutReal val) { - AUTO_TRACE(); + ASSERT3(finite(val)); auto columnPosition = std::find(positions.begin(), positions.end(), petscCol); if (columnPosition != positions.end()) { diff --git a/include/bout/scorepwrapper.hxx b/include/bout/scorepwrapper.hxx index 81761530f0..40c2232040 100644 --- a/include/bout/scorepwrapper.hxx +++ b/include/bout/scorepwrapper.hxx @@ -3,7 +3,6 @@ #include "bout/build_defines.hxx" -#include "bout/msg_stack.hxx" #include #if BOUT_HAS_SCOREP @@ -14,6 +13,18 @@ #define SCOREPLVL 0 #endif +/// The __PRETTY_FUNCTION__ variable is defined by GCC (and some other families) but is +/// not a part of the standard. The __func__ variable *is* a part of the c++11 standard so +/// we'd like to fall back to this if possible. However as these are variables/constants +/// and not macros we can't just check if __PRETTY_FUNCITON__ is defined or not. Instead +/// we need to say if we support this or not by defining BOUT_HAS_PRETTY_FUNCTION (to be +/// implemented in configure) +#if BOUT_HAS_PRETTY_FUNCTION +#define __thefunc__ __PRETTY_FUNCTION__ +#else +#define __thefunc__ __func__ +#endif + /// Instrument a function with scorep /// /// The scorep call is identical for all levels, so just define it here. diff --git a/include/bout/sys/timer.hxx b/include/bout/sys/timer.hxx index f3beba27b1..90fd632f62 100644 --- a/include/bout/sys/timer.hxx +++ b/include/bout/sys/timer.hxx @@ -133,5 +133,4 @@ public: static void printTimeReport(); }; -#define AUTO_TIME() Timer CONCATENATE(time_, __LINE__)(__thefunc__) #endif // BOUT_TIMER_H diff --git a/manual/doxygen/Doxyfile b/manual/doxygen/Doxyfile index e2fef90a8c..82cfa5a8a4 100644 --- a/manual/doxygen/Doxyfile +++ b/manual/doxygen/Doxyfile @@ -2059,7 +2059,6 @@ PREDEFINED = BACKTRACE \ BOUT_HAS_LAPACK \ BOUT_HAS_NETCDF \ BOUT_HAS_PETSC \ - BOUT_HAS_PRETTY_FUNCTION \ BOUT_HAS_PVODE \ BOUT_HAS_SCOREP \ BOUT_HAS_SLEPC \ diff --git a/manual/doxygen/Doxyfile_readthedocs b/manual/doxygen/Doxyfile_readthedocs index 94113490d9..0ddca11de0 100644 --- a/manual/doxygen/Doxyfile_readthedocs +++ b/manual/doxygen/Doxyfile_readthedocs @@ -1019,7 +1019,6 @@ PREDEFINED = BACKTRACE \ BOUT_HAS_LAPACK \ BOUT_HAS_NETCDF \ BOUT_HAS_PETSC \ - BOUT_HAS_PRETTY_FUNCTION \ BOUT_HAS_PVODE \ BOUT_HAS_SCOREP \ BOUT_HAS_SLEPC \ diff --git a/manual/sphinx/developer_docs/debugging.rst b/manual/sphinx/developer_docs/debugging.rst index 805cb5409a..fc8d80d9fc 100644 --- a/manual/sphinx/developer_docs/debugging.rst +++ b/manual/sphinx/developer_docs/debugging.rst @@ -37,11 +37,10 @@ add a ``-v -v`` flag to see ``output_debug`` messages. Message Stack ============= -The second utility BOUT++ has to help debugging is the message stack -using the `TRACE` (and related `AUTO_TRACE`) macro. These are very -useful for when a bug only occurs after a long time of running, and/or -only occasionally. The ``TRACE`` macro can simply be dropped in -anywhere in the code:: +The second utility BOUT++ has to help debugging is the message stack using the +`TRACE` macro. This is very useful for when a bug only occurs after a long time +of running, and/or only occasionally. The ``TRACE`` macro can simply be dropped +in anywhere in the code:: { TRACE("Some message here"); // message pushed @@ -95,11 +94,6 @@ the ``fmt`` syntax also used by the loggers:: TRACE("Value of i={}, some arbitrary {}", i, "string"); -There is also an ``AUTO_TRACE`` macro that automatically captures the -name of the function it's used in. This is used throughout the main -library, especially in functions where numerical issues are likely to -arise. - Backtrace ========= diff --git a/src/bout++.cxx b/src/bout++.cxx index 48ab96298b..9c859aaaa7 100644 --- a/src/bout++.cxx +++ b/src/bout++.cxx @@ -566,8 +566,6 @@ void printCompileTimeOptions() { output_info.write(_("\tNetCDF support {}{}\n"), is_enabled(has_netcdf), netcdf_flavour); output_info.write(_("\tADIOS2 support {}\n"), is_enabled(has_adios2)); output_info.write(_("\tPETSc support {}\n"), is_enabled(has_petsc)); - output_info.write(_("\tPretty function name support {}\n"), - is_enabled(has_pretty_function)); output_info.write(_("\tPVODE support {}\n"), is_enabled(has_pvode)); output_info.write(_("\tScore-P support {}\n"), is_enabled(has_scorep)); output_info.write(_("\tSLEPc support {}\n"), is_enabled(has_slepc)); @@ -696,7 +694,6 @@ void addBuildFlagsToOptions(Options& options) { options["has_umpire"].force(bout::build::has_umpire); options["has_caliper"].force(bout::build::has_caliper); options["has_raja"].force(bout::build::has_raja); - options["has_pretty_function"].force(bout::build::has_pretty_function); options["has_pvode"].force(bout::build::has_pvode); options["has_scorep"].force(bout::build::has_scorep); options["has_slepc"].force(bout::build::has_slepc); diff --git a/src/field/field_data.cxx b/src/field/field_data.cxx index b95c0462d9..b925cb1426 100644 --- a/src/field/field_data.cxx +++ b/src/field/field_data.cxx @@ -15,7 +15,6 @@ namespace bout { /// Throws if checks are enabled and trying to use a staggered /// location on a non-staggered mesh CELL_LOC normaliseLocation(CELL_LOC location, Mesh* mesh) { - AUTO_TRACE(); // CELL_DEFAULT always means CELL_CENTRE if (location == CELL_DEFAULT) { @@ -216,7 +215,6 @@ Mesh* FieldData::getMesh() const { } FieldData& FieldData::setLocation(CELL_LOC new_location) { - AUTO_TRACE(); location = bout::normaliseLocation(new_location, getMesh()); @@ -228,10 +226,7 @@ FieldData& FieldData::setLocation(CELL_LOC new_location) { return *this; } -CELL_LOC FieldData::getLocation() const { - AUTO_TRACE(); - return location; -} +CELL_LOC FieldData::getLocation() const { return location; } Coordinates* FieldData::getCoordinates() const { auto fieldCoordinates_shared = fieldCoordinates.lock(); diff --git a/src/field/field_factory.cxx b/src/field/field_factory.cxx index b93a39eeda..188a64cf0c 100644 --- a/src/field/field_factory.cxx +++ b/src/field/field_factory.cxx @@ -188,7 +188,6 @@ Field2D FieldFactory::create2D(const std::string& value, const Options* opt, Field2D FieldFactory::create2D(FieldGeneratorPtr gen, Mesh* localmesh, CELL_LOC loc, BoutReal t) const { - AUTO_TRACE(); if (localmesh == nullptr) { if (fieldmesh == nullptr) { @@ -220,7 +219,6 @@ Field3D FieldFactory::create3D(const std::string& value, const Options* opt, Field3D FieldFactory::create3D(FieldGeneratorPtr gen, Mesh* localmesh, CELL_LOC loc, BoutReal t) const { - AUTO_TRACE(); if (localmesh == nullptr) { if (fieldmesh == nullptr) { @@ -271,7 +269,6 @@ FieldPerp FieldFactory::createPerp(const std::string& value, const Options* opt, FieldPerp FieldFactory::createPerp(FieldGeneratorPtr gen, Mesh* localmesh, CELL_LOC loc, BoutReal t) const { - AUTO_TRACE(); if (localmesh == nullptr) { if (fieldmesh == nullptr) { diff --git a/src/field/initialprofiles.cxx b/src/field/initialprofiles.cxx index ded5aa9882..5e96d6005a 100644 --- a/src/field/initialprofiles.cxx +++ b/src/field/initialprofiles.cxx @@ -45,7 +45,6 @@ #include void initial_profile(const std::string& name, Field3D& var) { - AUTO_TRACE(); Mesh* localmesh = var.getMesh(); @@ -65,7 +64,6 @@ void initial_profile(const std::string& name, Field3D& var) { } void initial_profile(const std::string& name, Field2D& var) { - AUTO_TRACE(); Mesh* localmesh = var.getMesh(); @@ -85,7 +83,6 @@ void initial_profile(const std::string& name, Field2D& var) { } void initial_profile(const std::string& name, Vector2D& var) { - AUTO_TRACE(); if (var.covariant) { initial_profile(name + "_x", var.x); @@ -99,7 +96,6 @@ void initial_profile(const std::string& name, Vector2D& var) { } void initial_profile(const std::string& name, Vector3D& var) { - AUTO_TRACE(); if (var.covariant) { initial_profile(name + "_x", var.x); diff --git a/src/field/vecops.cxx b/src/field/vecops.cxx index 5f34e2af02..4d62d1a1d7 100644 --- a/src/field/vecops.cxx +++ b/src/field/vecops.cxx @@ -119,7 +119,7 @@ Vector3D Grad_perp(const Field3D& f, CELL_LOC outloc, const std::string& method) } Vector2D Grad_perp(const Field2D& f, CELL_LOC outloc, const std::string& method) { - AUTO_TRACE(); + SCOREP0(); ASSERT1(outloc == CELL_DEFAULT || outloc == f.getLocation()); @@ -370,7 +370,7 @@ Field3D V_dot_Grad(const Vector3D& v, const Field3D& f) { // operation (addition) between the two input types. template R V_dot_Grad(const T& v, const F& a) { - AUTO_TRACE(); + SCOREP0(); ASSERT1(v.getLocation() == a.getLocation()); ASSERT1(v.getLocation() != CELL_VSHIFT); diff --git a/src/invert/laplace/impls/petsc3damg/petsc3damg.cxx b/src/invert/laplace/impls/petsc3damg/petsc3damg.cxx index efca1d70be..3be5e43e63 100644 --- a/src/invert/laplace/impls/petsc3damg/petsc3damg.cxx +++ b/src/invert/laplace/impls/petsc3damg/petsc3damg.cxx @@ -174,7 +174,6 @@ void setBC(PetscVector& rhs, const Field3D& b_in, } Field3D LaplacePetsc3dAmg::solve(const Field3D& b_in, const Field3D& x0) { - AUTO_TRACE(); // Timing reported in the log files. Includes any matrix construction. // The timing for just the solve phase can be retrieved from the "petscsolve" diff --git a/src/mesh/data/gridfromfile.cxx b/src/mesh/data/gridfromfile.cxx index 5078882136..fba64eaa59 100644 --- a/src/mesh/data/gridfromfile.cxx +++ b/src/mesh/data/gridfromfile.cxx @@ -143,7 +143,6 @@ bool GridFile::getField(Mesh* m, T& var, const std::string& name, BoutReal def, "templated GridFile::getField only works for Field2D, Field3D or FieldPerp"); Timer timer("io"); - AUTO_TRACE(); if (not data.isSet(name)) { // Variable not found diff --git a/src/mesh/index_derivs.cxx b/src/mesh/index_derivs.cxx index add67a77c8..595081e3ae 100644 --- a/src/mesh/index_derivs.cxx +++ b/src/mesh/index_derivs.cxx @@ -423,7 +423,7 @@ class FFTDerivativeType { public: template void standard(const T& var, T& result, const std::string& region) const { - AUTO_TRACE(); + ASSERT2(meta.derivType == DERIV::Standard) ASSERT2(var.getMesh()->getNguard(direction) >= nGuards); ASSERT2(direction == DIRECTION::Z); // Only in Z for now @@ -479,7 +479,7 @@ class FFTDerivativeType { template void upwindOrFlux(const T& UNUSED(vel), const T& UNUSED(var), T& UNUSED(result), const std::string& UNUSED(region)) const { - AUTO_TRACE(); + throw BoutException("The FFT METHOD isn't available in upwind/Flux"); } static constexpr metaData meta{"FFT", 0, DERIV::Standard}; @@ -489,7 +489,7 @@ class FFT2ndDerivativeType { public: template void standard(const T& var, T& result, const std::string& region) const { - AUTO_TRACE(); + ASSERT2(meta.derivType == DERIV::StandardSecond); ASSERT2(var.getMesh()->getNguard(direction) >= nGuards); ASSERT2(direction == DIRECTION::Z); // Only in Z for now @@ -536,7 +536,7 @@ class FFT2ndDerivativeType { template void upwindOrFlux(const T& UNUSED(vel), const T& UNUSED(var), T& UNUSED(result), const std::string& UNUSED(region)) const { - AUTO_TRACE(); + throw BoutException("The FFT METHOD isn't available in upwind/Flux"); } static constexpr metaData meta{"FFT", 0, DERIV::StandardSecond}; @@ -552,14 +552,14 @@ class SplitFluxDerivativeType { public: template void standard(const T&, T&, const std::string) const { - AUTO_TRACE(); + throw BoutException("The SPLIT method isn't available for standard"); } template void upwindOrFlux(const T& vel, const T& var, T& result, const std::string region) const { - AUTO_TRACE(); + // Split into an upwind and a central differencing part // d/dx(v*f) = v*d/dx(f) + f*d/dx(v) result = bout::derivatives::index::flowDerivative( diff --git a/src/mesh/parallel/shiftedmetricinterp.cxx b/src/mesh/parallel/shiftedmetricinterp.cxx index 7f3637e79c..4543c4c3fb 100644 --- a/src/mesh/parallel/shiftedmetricinterp.cxx +++ b/src/mesh/parallel/shiftedmetricinterp.cxx @@ -211,7 +211,6 @@ void ShiftedMetricInterp::checkInputGrid() { * Calculate the Y up and down fields */ void ShiftedMetricInterp::calcParallelSlices(Field3D& f) { - AUTO_TRACE(); // Ensure that yup and ydown are different fields f.splitParallelSlices(); diff --git a/src/physics/smoothing.cxx b/src/physics/smoothing.cxx index 0a1391907f..d8f7fb8b6b 100644 --- a/src/physics/smoothing.cxx +++ b/src/physics/smoothing.cxx @@ -352,7 +352,7 @@ BoutReal Average_XY(const Field2D& var) { BoutReal Vol_Integral(const Field2D& var) { #if BOUT_USE_METRIC_3D - AUTO_TRACE(); + throw BoutException("Vol_Intregral currently incompatible with 3D metrics"); #else Mesh* mesh = var.getMesh(); diff --git a/src/solver/impls/adams_bashforth/adams_bashforth.cxx b/src/solver/impls/adams_bashforth/adams_bashforth.cxx index 79161fcdbf..bb81e3d53f 100644 --- a/src/solver/impls/adams_bashforth/adams_bashforth.cxx +++ b/src/solver/impls/adams_bashforth/adams_bashforth.cxx @@ -14,7 +14,6 @@ namespace { BoutReal lagrange_at_position_denominator(const std::deque& grid, const int position, const int order) { - AUTO_TRACE(); const auto xj = grid[position]; @@ -28,7 +27,7 @@ BoutReal lagrange_at_position_denominator(const std::deque& grid, BoutReal lagrange_at_position_numerator(const BoutReal varX, const std::deque& grid, const int position, const int order) { - AUTO_TRACE(); + BoutReal result = 1.0; for (int i = 0; i < order; i++) { result *= (i != position) ? (varX - grid[i]) : 1.0; @@ -55,7 +54,7 @@ BoutReal lagrange_interpolate(BoutReal start, BoutReal end, BoutReal integrate_lagrange_curve_nc9(const BoutReal start, const BoutReal end, const std::deque& points, const int position) { - AUTO_TRACE(); + constexpr std::size_t size = 9; constexpr BoutReal fac = 4.0 / 14175.0; constexpr std::array facs{989.0 * fac, 5888.0 * fac, -928.0 * fac, @@ -68,7 +67,7 @@ BoutReal integrate_lagrange_curve_nc9(const BoutReal start, const BoutReal end, BoutReal integrate_lagrange_curve_nc8(const BoutReal start, const BoutReal end, const std::deque& points, const int position) { - AUTO_TRACE(); + constexpr std::size_t size = 8; constexpr BoutReal fac = 7.0 / 17280.0; constexpr std::array facs{751.0 * fac, 3577.0 * fac, 1323.0 * fac, @@ -81,7 +80,7 @@ BoutReal integrate_lagrange_curve_nc8(const BoutReal start, const BoutReal end, BoutReal integrate_lagrange_curve_nc7(const BoutReal start, const BoutReal end, const std::deque& points, const int position) { - AUTO_TRACE(); + constexpr std::size_t size = 7; constexpr BoutReal fac = 1.0 / 140.0; constexpr std::array facs{41.0 * fac, 216.0 * fac, 27.0 * fac, @@ -94,7 +93,7 @@ BoutReal integrate_lagrange_curve_nc7(const BoutReal start, const BoutReal end, BoutReal integrate_lagrange_curve_nc6(const BoutReal start, const BoutReal end, const std::deque& points, const int position) { - AUTO_TRACE(); + constexpr std::size_t size = 6; constexpr BoutReal fac = 5.0 / 288.0; constexpr std::array facs{19.0 * fac, 75.0 * fac, 50.0 * fac, @@ -106,7 +105,7 @@ BoutReal integrate_lagrange_curve_nc6(const BoutReal start, const BoutReal end, BoutReal integrate_lagrange_curve_nc5(const BoutReal start, const BoutReal end, const std::deque& points, const int position) { - AUTO_TRACE(); + constexpr std::size_t size = 5; constexpr BoutReal fac = 2.0 / 45.0; constexpr std::array facs{7.0 * fac, 32.0 * fac, 12.0 * fac, 32.0 * fac, @@ -118,7 +117,7 @@ BoutReal integrate_lagrange_curve_nc5(const BoutReal start, const BoutReal end, BoutReal integrate_lagrange_curve_nc4(const BoutReal start, const BoutReal end, const std::deque& points, const int position) { - AUTO_TRACE(); + constexpr std::size_t size = 4; constexpr BoutReal fac = 3.0 / 8.0; constexpr std::array facs{1.0 * fac, 3.0 * fac, 3.0 * fac, 1.0 * fac}; @@ -129,7 +128,7 @@ BoutReal integrate_lagrange_curve_nc4(const BoutReal start, const BoutReal end, BoutReal integrate_lagrange_curve_nc3(const BoutReal start, const BoutReal end, const std::deque& points, const int position) { - AUTO_TRACE(); + constexpr std::size_t size = 3; constexpr BoutReal fac = 1.0 / 3.0; constexpr std::array facs{1.0 * fac, 4.0 * fac, 1.0 * fac}; @@ -140,7 +139,7 @@ BoutReal integrate_lagrange_curve_nc3(const BoutReal start, const BoutReal end, BoutReal integrate_lagrange_curve_nc2(const BoutReal start, const BoutReal end, const std::deque& points, const int position) { - AUTO_TRACE(); + constexpr std::size_t size = 2; constexpr BoutReal fac = 1.0 / 2.0; constexpr std::array facs{1.0 * fac, 1.0 * fac}; @@ -151,7 +150,6 @@ BoutReal integrate_lagrange_curve_nc2(const BoutReal start, const BoutReal end, BoutReal integrate_lagrange_curve(const BoutReal start, const BoutReal end, const std::deque& points, const int position, const int order) { - AUTO_TRACE(); switch (order) { case 1: @@ -179,7 +177,7 @@ BoutReal integrate_lagrange_curve(const BoutReal start, const BoutReal end, std::vector get_adams_bashforth_coefficients(const BoutReal nextPoint, const std::deque& points, const int order) { - AUTO_TRACE(); + ASSERT2(static_cast(order) <= points.size()); std::vector result; @@ -235,7 +233,7 @@ BoutReal get_timestep_limit(const BoutReal error, const BoutReal tolerance, /// over all processors. BoutReal get_error(const Array& stateApprox, const Array& stateAccurate) { - AUTO_TRACE(); + BoutReal local_result = 0.0; BoutReal err = 0.0; @@ -287,12 +285,12 @@ AdamsBashforthSolver::AdamsBashforthSolver(Options* options) .withDefault(getOutputTimestep())), timestep( (*options)["timestep"].doc("Starting timestep").withDefault(max_timestep)) { - AUTO_TRACE(); + canReset = true; } void AdamsBashforthSolver::setMaxTimestep(BoutReal dt) { - AUTO_TRACE(); + if (dt > timestep) { return; // Already less than this } @@ -345,7 +343,6 @@ int AdamsBashforthSolver::init() { } void AdamsBashforthSolver::resetInternalFields() { - AUTO_TRACE(); // History and times history.clear(); @@ -360,7 +357,6 @@ void AdamsBashforthSolver::resetInternalFields() { } int AdamsBashforthSolver::run() { - AUTO_TRACE(); // Just for developer diagnostics int nwasted = 0; @@ -563,7 +559,6 @@ int AdamsBashforthSolver::run() { BoutReal AdamsBashforthSolver::take_step(const BoutReal timeIn, const BoutReal dt, const int order, Array& current, Array& result) { - AUTO_TRACE(); Array full_update = AB_integrate(nlocal, timeIn + dt, times, history, order); diff --git a/src/solver/impls/split-rk/split-rk.cxx b/src/solver/impls/split-rk/split-rk.cxx index cd6bd1718c..fd9a99a6c5 100644 --- a/src/solver/impls/split-rk/split-rk.cxx +++ b/src/solver/impls/split-rk/split-rk.cxx @@ -35,7 +35,6 @@ SplitRK::SplitRK(Options* opts) } int SplitRK::init() { - AUTO_TRACE(); Solver::init(); output.write(_("\n\tSplit Runge-Kutta-Legendre and SSP-RK3 solver\n")); @@ -79,7 +78,6 @@ int SplitRK::init() { } int SplitRK::run() { - AUTO_TRACE(); for (int step = 0; step < getNumberOutputSteps(); step++) { // Take an output step diff --git a/src/solver/solver.cxx b/src/solver/solver.cxx index a3f6a874f6..ea7866051b 100644 --- a/src/solver/solver.cxx +++ b/src/solver/solver.cxx @@ -636,7 +636,7 @@ std::string Solver::createRunID() const { } std::string Solver::getRunID() const { - AUTO_TRACE(); + if (run_id == default_run_id) { throw BoutException("run_id not set!"); } @@ -644,7 +644,7 @@ std::string Solver::getRunID() const { } std::string Solver::getRunRestartFrom() const { - AUTO_TRACE(); + // Check against run_id, because this might not be a restarted run if (run_id == default_run_id) { throw BoutException("run_restart_from not set!"); diff --git a/src/sys/bout_types.cxx b/src/sys/bout_types.cxx index 35d37f11be..f5e971af78 100644 --- a/src/sys/bout_types.cxx +++ b/src/sys/bout_types.cxx @@ -6,7 +6,7 @@ namespace { template const std::string& safeAt(const std::map& mymap, T t) { - AUTO_TRACE(); + auto found = mymap.find(t); if (found == mymap.end()) { throw BoutException("Did not find enum {:d}", static_cast(t)); @@ -16,7 +16,7 @@ const std::string& safeAt(const std::map& mymap, T t) { template const T& safeAt(const std::map& mymap, const std::string& s) { - AUTO_TRACE(); + auto found = mymap.find(s); if (found == mymap.end()) { throw BoutException("Did not find enum {:s}", s); @@ -26,7 +26,7 @@ const T& safeAt(const std::map& mymap, const std::string& s) { } // namespace std::string toString(CELL_LOC location) { - AUTO_TRACE(); + const static std::map CELL_LOCtoString = { ENUMSTR(CELL_DEFAULT), ENUMSTR(CELL_CENTRE), ENUMSTR(CELL_XLOW), ENUMSTR(CELL_YLOW), ENUMSTR(CELL_ZLOW), ENUMSTR(CELL_VSHIFT)}; @@ -35,7 +35,7 @@ std::string toString(CELL_LOC location) { } CELL_LOC CELL_LOCFromString(const std::string& location_string) { - AUTO_TRACE(); + const static std::map stringtoCELL_LOC = { STRENUM(CELL_DEFAULT), STRENUM(CELL_CENTRE), STRENUM(CELL_XLOW), STRENUM(CELL_YLOW), STRENUM(CELL_ZLOW), STRENUM(CELL_VSHIFT)}; @@ -44,7 +44,7 @@ CELL_LOC CELL_LOCFromString(const std::string& location_string) { } std::string toString(DIFF_METHOD location) { - AUTO_TRACE(); + const static std::map DIFF_METHODtoString = { {DIFF_DEFAULT, "DEFAULT"}, {DIFF_U1, "U1"}, {DIFF_U2, "U2"}, {DIFF_U3, "U3"}, {DIFF_C2, "C2"}, {DIFF_C4, "C4"}, {DIFF_S2, "S2"}, {DIFF_W2, "W2"}, @@ -54,7 +54,7 @@ std::string toString(DIFF_METHOD location) { } std::string toString(REGION region) { - AUTO_TRACE(); + const static std::map REGIONtoString = { ENUMSTR(RGN_ALL), ENUMSTR(RGN_NOBNDRY), ENUMSTR(RGN_NOX), ENUMSTR(RGN_NOY), ENUMSTR(RGN_NOZ)}; @@ -62,7 +62,7 @@ std::string toString(REGION region) { } std::string toString(DIRECTION direction) { - AUTO_TRACE(); + const static std::map DIRECTIONtoString = { {DIRECTION::X, "X"}, {DIRECTION::Y, "Y"}, @@ -116,7 +116,7 @@ bool areDirectionsCompatible(const DirectionTypes& d1, const DirectionTypes& d2) } std::string toString(STAGGER stagger) { - AUTO_TRACE(); + const static std::map STAGGERtoString = { {STAGGER::None, "No staggering"}, {STAGGER::C2L, "Centre to Low"}, @@ -126,7 +126,7 @@ std::string toString(STAGGER stagger) { } std::string toString(DERIV deriv) { - AUTO_TRACE(); + const static std::map DERIVtoString = { {DERIV::Standard, "Standard"}, {DERIV::StandardSecond, "Standard -- second order"}, @@ -138,7 +138,7 @@ std::string toString(DERIV deriv) { } std::string toString(YDirectionType d) { - AUTO_TRACE(); + const static std::map YDirectionTypeToString = { {YDirectionType::Standard, "Standard"}, {YDirectionType::Aligned, "Aligned"}}; @@ -146,7 +146,7 @@ std::string toString(YDirectionType d) { } YDirectionType YDirectionTypeFromString(const std::string& y_direction_string) { - AUTO_TRACE(); + const static std::map stringToYDirectionType = { {"Standard", YDirectionType::Standard}, {"Aligned", YDirectionType::Aligned}}; @@ -154,7 +154,7 @@ YDirectionType YDirectionTypeFromString(const std::string& y_direction_string) { } std::string toString(ZDirectionType d) { - AUTO_TRACE(); + const static std::map ZDirectionTypeToString = { {ZDirectionType::Standard, "Standard"}, {ZDirectionType::Average, "Average"}}; @@ -162,7 +162,7 @@ std::string toString(ZDirectionType d) { } ZDirectionType ZDirectionTypeFromString(const std::string& z_direction_string) { - AUTO_TRACE(); + const static std::map stringToZDirectionType = { {"Standard", ZDirectionType::Standard}, {"Average", ZDirectionType::Average}}; diff --git a/src/sys/msg_stack.cxx b/src/sys/msg_stack.cxx index 502836324c..81eb6c4b0f 100644 --- a/src/sys/msg_stack.cxx +++ b/src/sys/msg_stack.cxx @@ -27,7 +27,7 @@ #include "bout/openmpwrap.hxx" #include #include -#include + #include #if BOUT_USE_OPENMP diff --git a/tests/integrated/test-backtrace/boutexcept.cxx b/tests/integrated/test-backtrace/boutexcept.cxx index bd965a9c2b..ed33a4c018 100644 --- a/tests/integrated/test-backtrace/boutexcept.cxx +++ b/tests/integrated/test-backtrace/boutexcept.cxx @@ -1,18 +1,9 @@ #include "bout/boutexception.hxx" #include "bout/msg_stack.hxx" -void troublemaker() { - AUTO_TRACE(); - throw BoutException("test"); -} -void f() { - AUTO_TRACE(); - troublemaker(); -} -void e() { - AUTO_TRACE(); - f(); -} +void troublemaker() { throw BoutException("test"); } +void f() { troublemaker(); } +void e() { f(); } int main() { e(); From 505d5adde26e2f70a129582b676bd99fcb85fafd Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 15:11:05 +0000 Subject: [PATCH 10/34] Remove uses of `TRACE` which are just the function name --- examples/6field-simple/elm_6f.cxx | 4 -- .../invertable_operator.cxx | 5 +-- include/bout/cyclic_reduction.hxx | 4 +- include/bout/invertable_operator.hxx | 25 ++++------- .../sphinx/user_docs/invertable_operator.rst | 2 - src/field/field2d.cxx | 36 ++++------------ src/field/field3d.cxx | 43 ++----------------- src/field/fieldperp.cxx | 3 -- src/field/vecops.cxx | 26 +++++------ src/field/vector2d.cxx | 2 +- src/field/vector3d.cxx | 2 +- .../laplace/impls/cyclic/cyclic_laplace.cxx | 1 - .../iterative_parallel_tri.cxx | 1 - .../impls/multigrid/multigrid_laplace.cxx | 5 --- src/invert/laplace/impls/pcr/pcr.cxx | 1 - .../laplace/impls/pcr_thomas/pcr_thomas.cxx | 1 - .../laplace/impls/petsc/petsc_laplace.cxx | 1 - src/invert/laplace/invert_laplace.cxx | 2 - .../impls/cyclic/laplacexz-cyclic.cxx | 2 +- .../laplacexz/impls/petsc/laplacexz-petsc.cxx | 8 ---- src/invert/parderiv/impls/cyclic/cyclic.cxx | 2 +- .../pardiv/impls/cyclic/pardiv_cyclic.cxx | 2 +- src/mesh/boundary_standard.cxx | 5 --- src/mesh/coordinates.cxx | 28 ++++++------ src/mesh/data/gridfromfile.cxx | 9 ++-- src/mesh/difops.cxx | 11 ----- src/mesh/fv_ops.cxx | 1 - src/mesh/impls/bout/boutmesh.cxx | 2 - src/mesh/index_derivs.cxx | 4 -- src/mesh/interpolation_xz.cxx | 4 -- src/mesh/invert3x3.hxx | 1 - src/mesh/mesh.cxx | 3 -- src/mesh/parallel/fci.cxx | 3 -- src/physics/physicsmodel.cxx | 1 - src/physics/smoothing.cxx | 14 +----- src/physics/sourcex.cxx | 4 -- .../impls/adams_bashforth/adams_bashforth.cxx | 2 - src/solver/impls/arkode/arkode.cxx | 3 -- src/solver/impls/cvode/cvode.cxx | 5 +-- src/solver/impls/euler/euler.cxx | 2 - src/solver/impls/ida/ida.cxx | 3 -- src/solver/impls/imex-bdf2/imex-bdf2.cxx | 3 -- src/solver/impls/petsc/petsc.cxx | 3 -- src/solver/impls/power/power.cxx | 2 - src/solver/impls/pvode/pvode.cxx | 2 - src/solver/impls/rk3-ssp/rk3-ssp.cxx | 2 - src/solver/impls/rk4/rk4.cxx | 4 -- src/solver/impls/rkgeneric/rkgeneric.cxx | 4 -- src/solver/impls/slepc/slepc.cxx | 2 - src/solver/impls/snes/snes.cxx | 5 --- src/solver/solver.cxx | 3 -- src/sys/options.cxx | 4 -- src/sys/options/options_ini.cxx | 6 +-- src/sys/optionsreader.cxx | 3 -- .../invertable_operator.cxx | 3 +- tests/integrated/test-vec/testVec.cxx | 2 - 56 files changed, 60 insertions(+), 271 deletions(-) diff --git a/examples/6field-simple/elm_6f.cxx b/examples/6field-simple/elm_6f.cxx index 40e4f7b3b3..24256333df 100644 --- a/examples/6field-simple/elm_6f.cxx +++ b/examples/6field-simple/elm_6f.cxx @@ -273,8 +273,6 @@ class Elm_6f : public PhysicsModel { * This function implements d2/dy2 where y is the poloidal coordinate theta */ - TRACE("Grad2_par2new( Field3D )"); - Field3D result = D2DY2(f); #if BOUT_USE_TRACK @@ -342,8 +340,6 @@ class Elm_6f : public PhysicsModel { // Parallel gradient along perturbed field-line Field3D Grad_parP(const Field3D& f, CELL_LOC loc = CELL_DEFAULT) { - TRACE("Grad_parP"); - Field3D result; if (parallel_lagrange || parallel_project) { diff --git a/examples/invertable_operator/invertable_operator.cxx b/examples/invertable_operator/invertable_operator.cxx index 57f9e24b08..99db7f7a1e 100644 --- a/examples/invertable_operator/invertable_operator.cxx +++ b/examples/invertable_operator/invertable_operator.cxx @@ -1,5 +1,4 @@ #include -#include #include #include @@ -26,7 +25,7 @@ class HW : public PhysicsModel { // Drop C term for now Field3D operator()(const Field3D& input) { - TRACE("myLaplacian::operator()"); + Timer timer("invertable_operator_operate"); Field3D result = A * input + D * Delp2(input); @@ -43,7 +42,7 @@ class HW : public PhysicsModel { // Drop C term for now Field3D operator()(const Field3D& input) { - TRACE("myLaplacian::operator()"); + Timer timer("invertable_operator_operate"); Field3D result = A * input + B * Laplace_perp(input); if (withDiv) { diff --git a/include/bout/cyclic_reduction.hxx b/include/bout/cyclic_reduction.hxx index d4c0920910..cf54b63059 100644 --- a/include/bout/cyclic_reduction.hxx +++ b/include/bout/cyclic_reduction.hxx @@ -47,7 +47,6 @@ //#define DIAGNOSE 1 #include "mpi.h" -#include "bout/msg_stack.hxx" #include "bout/utils.hxx" #include @@ -118,7 +117,6 @@ public: /// @param[in] b Diagonal values. Should have size [nsys][N] /// @param[in] c Right diagonal. Should have size [nsys][N] void setCoefs(const Matrix& a, const Matrix& b, const Matrix& c) { - TRACE("CyclicReduce::setCoefs"); int nsys = std::get<0>(a.shape()); @@ -169,7 +167,7 @@ public: /// @param[in] rhs Matrix storing Values of the rhs for each system /// @param[out] x Matrix storing the result for each system void solve(const Matrix& rhs, Matrix& x) { - TRACE("CyclicReduce::solve"); + ASSERT2(static_cast(std::get<0>(rhs.shape())) == Nsys); ASSERT2(static_cast(std::get<0>(x.shape())) == Nsys); ASSERT2(static_cast(std::get<1>(rhs.shape())) == N); diff --git a/include/bout/invertable_operator.hxx b/include/bout/invertable_operator.hxx index ffc0910dce..6dcd92897a 100644 --- a/include/bout/invertable_operator.hxx +++ b/include/bout/invertable_operator.hxx @@ -42,7 +42,6 @@ class InvertableOperator; #include #include #include -#include #include #include #include @@ -68,7 +67,7 @@ T identity(const T& in) { /// Pack a PetscVec from a Field template PetscErrorCode fieldToPetscVec(const T& in, Vec out) { - TRACE("fieldToPetscVec"); + Timer timer("invertable_operator_packing"); PetscScalar* vecData; @@ -93,7 +92,7 @@ PetscErrorCode fieldToPetscVec(const T& in, Vec out) { /// Pack a Field from a PetscVec template PetscErrorCode petscVecToField(Vec in, T& out) { - TRACE("petscVecToField"); + Timer timer("invertable_operator_packing"); const PetscScalar* vecData; @@ -142,7 +141,6 @@ public: /// Destructor just has to cleanup the PETSc owned objects. ~InvertableOperator() { - TRACE("InvertableOperator::destructor"); KSPDestroy(&ksp); MatDestroy(&matOperator); @@ -157,7 +155,7 @@ public: /// do this they can set alsoSetPreconditioner to false. void setOperatorFunction(const function_signature& func, bool alsoSetPreconditioner = true) { - TRACE("InvertableOperator::setOperatorFunction"); + operatorFunction = func; if (alsoSetPreconditioner) { preconditionerFunction = func; @@ -166,15 +164,12 @@ public: /// Allow the user to override the existing preconditioner function void setPreconditionerFunction(const function_signature& func) { - TRACE("InvertableOperator::setPreconditionerFunction"); + preconditionerFunction = func; } /// Provide a way to apply the operator to a Field - T operator()(const T& input) { - TRACE("InvertableOperator::operator()"); - return operatorFunction(input); - } + T operator()(const T& input) { return operatorFunction(input); } /// Provide a synonym for applying the operator to a Field T apply(const T& input) { return operator()(input); } @@ -184,7 +179,6 @@ public: /// represents. Not actually required by any of the setup so this should /// probably be moved to a separate place (maybe the constructor). PetscErrorCode setup() { - TRACE("InvertableOperator::setup"); Timer timer("invertable_operator_setup"); if (doneSetup) { @@ -394,7 +388,7 @@ public: /// of the operator we represent. Should probably provide an overload or similar as a /// way of setting the initial guess. T invert(const T& rhsField) { - TRACE("InvertableOperator::invert"); + Timer timer("invertable_operator_invert"); if (!doneSetup) { @@ -441,7 +435,6 @@ public: /// applying the registered function on the calculated inverse gives /// back the initial values. bool verify(const T& rhsIn, BoutReal tol = 1.0e-5) { - TRACE("InvertableOperator::verify"); T result = invert(rhsIn); localmesh->communicate(result); @@ -460,7 +453,7 @@ public: /// that as the Timer "labels" are not unique to an instance the time /// reported is summed across all different instances. static void reportTime() { - TRACE("InvertableOperator::reportTime"); + BoutReal time_setup = Timer::resetTime("invertable_operator_setup"); BoutReal time_invert = Timer::resetTime("invertable_operator_invert"); BoutReal time_packing = Timer::resetTime("invertable_operator_packing"); @@ -500,7 +493,7 @@ private: /// Copies data from v1 into a field of type T, calls the function on this and then /// copies the result into the v2 argument. static PetscErrorCode functionWrapper(Mat m, Vec v1, Vec v2) { - TRACE("InvertableOperator::functionWrapper"); + InvertableOperator* ctx; auto ierr = MatShellGetContext(m, &ctx); T tmpField(ctx->localmesh); @@ -531,7 +524,7 @@ private: /// Copies data from v1 into a field of type T, calls the function on this and then /// copies the result into the v2 argument. static PetscErrorCode preconditionerWrapper(Mat m, Vec v1, Vec v2) { - TRACE("InvertableOperator::functionWrapper"); + InvertableOperator* ctx; auto ierr = MatShellGetContext(m, &ctx); T tmpField(ctx->localmesh); diff --git a/manual/sphinx/user_docs/invertable_operator.rst b/manual/sphinx/user_docs/invertable_operator.rst index 92b7efd288..8f92796c9c 100644 --- a/manual/sphinx/user_docs/invertable_operator.rst +++ b/manual/sphinx/user_docs/invertable_operator.rst @@ -48,7 +48,6 @@ the ``operator()`` call:: // Drop C term for now Field3D operator()(const Field3D &input) { - TRACE("myLaplacian::operator()"); Timer timer("invertable_operator_operate"); Field3D result = A * input + D * Delp2(input); @@ -68,7 +67,6 @@ A more complete example is :: // Drop C term for now Field3D operator()(const Field3D &input) { - TRACE("myLaplacian::operator()"); Timer timer("invertable_operator_operate"); Field3D result = A * input + D * Delp2(input); diff --git a/src/field/field2d.cxx b/src/field/field2d.cxx index c8b9ebb689..01f2d8c4a6 100644 --- a/src/field/field2d.cxx +++ b/src/field/field2d.cxx @@ -25,28 +25,21 @@ * **************************************************************************/ -#include "bout/build_config.hxx" - -#include -#include - -#include // for mesh - -#include - -#include +#include "bout/build_defines.hxx" +#include #include #include - +#include #include +#include +#include // for mesh #include -#include - #include -#include +#include +#include -#include +#include Field2D::Field2D(Mesh* localmesh, CELL_LOC location_in, DirectionTypes directions_in) : Field(localmesh, location_in, directions_in) { @@ -62,7 +55,6 @@ Field2D::Field2D(Mesh* localmesh, CELL_LOC location_in, DirectionTypes direction } Field2D::Field2D(const Field2D& f) : Field(f), data(f.data) { - TRACE("Field2D(Field2D&)"); #if BOUT_USE_TRACK name = f.name; @@ -145,8 +137,6 @@ Field2D& Field2D::operator=(const Field2D& rhs) { return (*this); // skip this assignment } - TRACE("Field2D: Assignment from Field2D"); - Field::operator=(rhs); // Copy the data and data sizes @@ -165,8 +155,6 @@ Field2D& Field2D::operator=(Field2D&& rhs) noexcept { return (*this); // skip this assignment } - TRACE("Field2D: Move assignment from Field2D"); - // Move the data and data sizes nx = rhs.nx; ny = rhs.ny; @@ -185,7 +173,6 @@ Field2D& Field2D::operator=(const BoutReal rhs) { name = ""; #endif - TRACE("Field2D = BoutReal"); allocate(); BOUT_FOR(i, getRegion("RGN_ALL")) { (*this)[i] = rhs; } @@ -196,7 +183,6 @@ Field2D& Field2D::operator=(const BoutReal rhs) { ///////////////////// BOUNDARY CONDITIONS ////////////////// void Field2D::applyBoundary(bool init) { - TRACE("Field2D::applyBoundary()"); #if CHECK > 0 if (init) { @@ -218,7 +204,6 @@ void Field2D::applyBoundary(bool init) { } void Field2D::applyBoundary(BoutReal time) { - TRACE("Field2D::applyBoundary(time)"); #if CHECK > 0 if (not isBoundarySet()) { @@ -234,7 +219,6 @@ void Field2D::applyBoundary(BoutReal time) { } void Field2D::applyBoundary(const std::string& condition) { - TRACE("Field2D::applyBoundary(condition)"); checkData(*this); @@ -268,7 +252,7 @@ void Field2D::applyBoundary(const std::string& condition) { } void Field2D::applyBoundary(const std::string& region, const std::string& condition) { - TRACE("Field2D::applyBoundary(string, string)"); + checkData(*this); /// Get the boundary factory (singleton) @@ -310,7 +294,6 @@ void Field2D::applyBoundary(const std::string& region, const std::string& condit } void Field2D::applyTDerivBoundary() { - TRACE("Field2D::applyTDerivBoundary()"); checkData(*this); ASSERT1(deriv != nullptr); @@ -322,7 +305,6 @@ void Field2D::applyTDerivBoundary() { } void Field2D::setBoundaryTo(const Field2D& f2d) { - TRACE("Field2D::setBoundary(const Field2D&)"); checkData(f2d); diff --git a/src/field/field3d.cxx b/src/field/field3d.cxx index 4c5ffa9748..9821c638f7 100644 --- a/src/field/field3d.cxx +++ b/src/field/field3d.cxx @@ -25,7 +25,7 @@ * **************************************************************************/ -#include "bout/build_config.hxx" +#include "bout/build_defines.hxx" #include #include @@ -43,7 +43,6 @@ #include #include #include -#include #include #include @@ -67,8 +66,6 @@ Field3D::Field3D(const Field3D& f) : Field(f), data(f.data), yup_fields(f.yup_fields), ydown_fields(f.ydown_fields), regionID(f.regionID) { - TRACE("Field3D(Field3D&)"); - if (fieldmesh) { nx = fieldmesh->LocalNx; ny = fieldmesh->LocalNy; @@ -78,8 +75,6 @@ Field3D::Field3D(const Field3D& f) Field3D::Field3D(const Field2D& f) : Field(f) { - TRACE("Field3D: Copy constructor from Field2D"); - nx = fieldmesh->LocalNx; ny = fieldmesh->LocalNy; nz = fieldmesh->LocalNz; @@ -89,15 +84,12 @@ Field3D::Field3D(const Field2D& f) : Field(f) { Field3D::Field3D(const BoutReal val, Mesh* localmesh) : Field3D(localmesh) { - TRACE("Field3D: Copy constructor from value"); - *this = val; } Field3D::Field3D(Array data_in, Mesh* localmesh, CELL_LOC datalocation, DirectionTypes directions_in) : Field(localmesh, datalocation, directions_in), data(std::move(data_in)) { - TRACE("Field3D: Copy constructor from Array and Mesh"); nx = fieldmesh->LocalNx; ny = fieldmesh->LocalNy; @@ -137,7 +129,6 @@ Field3D* Field3D::timeDeriv() { } void Field3D::splitParallelSlices() { - TRACE("Field3D::splitParallelSlices"); if (hasParallelSlices()) { return; @@ -152,7 +143,6 @@ void Field3D::splitParallelSlices() { } void Field3D::clearParallelSlices() { - TRACE("Field3D::clearParallelSlices"); if (!hasParallelSlices()) { return; @@ -245,8 +235,6 @@ Field3D& Field3D::operator=(const Field3D& rhs) { return (*this); // skip this assignment } - TRACE("Field3D: Assignment from Field3D"); - // Copy base slice Field::operator=(rhs); @@ -266,7 +254,6 @@ Field3D& Field3D::operator=(const Field3D& rhs) { } Field3D& Field3D::operator=(Field3D&& rhs) { - TRACE("Field3D: Assignment from Field3D"); // Move parallel slices or delete existing ones. yup_fields = std::move(rhs.yup_fields); @@ -287,7 +274,6 @@ Field3D& Field3D::operator=(Field3D&& rhs) { } Field3D& Field3D::operator=(const Field2D& rhs) { - TRACE("Field3D = Field2D"); /// Check that the data is allocated ASSERT1(rhs.isAllocated()); @@ -314,7 +300,6 @@ Field3D& Field3D::operator=(const Field2D& rhs) { } void Field3D::operator=(const FieldPerp& rhs) { - TRACE("Field3D = FieldPerp"); ASSERT1_FIELDS_COMPATIBLE(*this, rhs); /// Check that the data is allocated @@ -333,7 +318,6 @@ void Field3D::operator=(const FieldPerp& rhs) { } Field3D& Field3D::operator=(const BoutReal val) { - TRACE("Field3D = BoutReal"); // Delete existing parallel slices. We don't copy parallel slices, so any // that currently exist will be incorrect. @@ -355,7 +339,6 @@ Field3D& Field3D::calcParallelSlices() { ///////////////////// BOUNDARY CONDITIONS ////////////////// void Field3D::applyBoundary(bool init) { - TRACE("Field3D::applyBoundary()"); #if CHECK > 0 if (init) { @@ -378,7 +361,6 @@ void Field3D::applyBoundary(bool init) { } void Field3D::applyBoundary(BoutReal t) { - TRACE("Field3D::applyBoundary()"); #if CHECK > 0 if (not isBoundarySet()) { @@ -395,7 +377,6 @@ void Field3D::applyBoundary(BoutReal t) { } void Field3D::applyBoundary(const std::string& condition) { - TRACE("Field3D::applyBoundary(condition)"); checkData(*this); @@ -413,7 +394,7 @@ void Field3D::applyBoundary(const std::string& condition) { } void Field3D::applyBoundary(const std::string& region, const std::string& condition) { - TRACE("Field3D::applyBoundary(string, string)"); + checkData(*this); /// Get the boundary factory (singleton) @@ -439,7 +420,6 @@ void Field3D::applyBoundary(const std::string& region, const std::string& condit } void Field3D::applyTDerivBoundary() { - TRACE("Field3D::applyTDerivBoundary()"); checkData(*this); ASSERT1(deriv != nullptr); @@ -451,7 +431,6 @@ void Field3D::applyTDerivBoundary() { } void Field3D::setBoundaryTo(const Field3D& f3d) { - TRACE("Field3D::setBoundary(const Field3D&)"); checkData(f3d); @@ -475,8 +454,6 @@ void Field3D::setBoundaryTo(const Field3D& f3d) { void Field3D::applyParallelBoundary() { - TRACE("Field3D::applyParallelBoundary()"); - checkData(*this); if (isFci()) { ASSERT1(hasParallelSlices()); @@ -493,8 +470,6 @@ void Field3D::applyParallelBoundary() { void Field3D::applyParallelBoundary(BoutReal t) { - TRACE("Field3D::applyParallelBoundary(t)"); - checkData(*this); if (isFci()) { ASSERT1(hasParallelSlices()); @@ -511,8 +486,6 @@ void Field3D::applyParallelBoundary(BoutReal t) { void Field3D::applyParallelBoundary(const std::string& condition) { - TRACE("Field3D::applyParallelBoundary(condition)"); - checkData(*this); if (isFci()) { ASSERT1(hasParallelSlices()); @@ -535,8 +508,6 @@ void Field3D::applyParallelBoundary(const std::string& condition) { void Field3D::applyParallelBoundary(const std::string& region, const std::string& condition) { - TRACE("Field3D::applyParallelBoundary(region, condition)"); - checkData(*this); if (isFci()) { ASSERT1(hasParallelSlices()); @@ -562,8 +533,6 @@ void Field3D::applyParallelBoundary(const std::string& region, void Field3D::applyParallelBoundary(const std::string& region, const std::string& condition, Field3D* f) { - TRACE("Field3D::applyParallelBoundary(region, condition, f)"); - checkData(*this); if (isFci()) { ASSERT1(hasParallelSlices()); @@ -599,7 +568,7 @@ Field3D operator-(const Field3D& f) { return -1.0 * f; } //////////////// NON-MEMBER FUNCTIONS ////////////////// Field3D pow(const Field3D& lhs, const Field2D& rhs, const std::string& rgn) { - TRACE("pow(Field3D, Field2D)"); + // Check if the inputs are allocated checkData(lhs); checkData(rhs); @@ -615,7 +584,6 @@ Field3D pow(const Field3D& lhs, const Field2D& rhs, const std::string& rgn) { } FieldPerp pow(const Field3D& lhs, const FieldPerp& rhs, const std::string& rgn) { - TRACE("pow(Field3D, FieldPerp)"); checkData(lhs); checkData(rhs); @@ -635,7 +603,6 @@ FieldPerp pow(const Field3D& lhs, const FieldPerp& rhs, const std::string& rgn) // Friend functions Field3D filter(const Field3D& var, int N0, const std::string& rgn) { - TRACE("filter(Field3D, int)"); checkData(var); @@ -681,7 +648,6 @@ Field3D filter(const Field3D& var, int N0, const std::string& rgn) { // Fourier filter in z with zmin Field3D lowPass(const Field3D& var, int zmax, bool keep_zonal, const std::string& rgn) { - TRACE("lowPass(Field3D, {}, {})", zmax, keep_zonal); checkData(var); int ncz = var.getNz(); @@ -731,7 +697,7 @@ Field3D lowPass(const Field3D& var, int zmax, bool keep_zonal, const std::string * Use FFT to shift by an angle in the Z direction */ void shiftZ(Field3D& var, int jx, int jy, double zangle) { - TRACE("shiftZ"); + checkData(var); var.allocate(); // Ensure that var is unique Mesh* localmesh = var.getMesh(); @@ -800,7 +766,6 @@ void checkData(const Field3D& f, const std::string& region) { #endif Field2D DC(const Field3D& f, const std::string& rgn) { - TRACE("DC(Field3D)"); checkData(f); diff --git a/src/field/fieldperp.cxx b/src/field/fieldperp.cxx index ca9bdc0397..d74a986473 100644 --- a/src/field/fieldperp.cxx +++ b/src/field/fieldperp.cxx @@ -31,7 +31,6 @@ #include #include #include -#include #include FieldPerp::FieldPerp(Mesh* localmesh, CELL_LOC location_in, int yindex_in, @@ -51,7 +50,6 @@ FieldPerp::FieldPerp(Array data_in, Mesh* localmesh, CELL_LOC location int yindex_in, DirectionTypes directions) : Field(localmesh, location_in, directions), yindex(yindex_in), nx(fieldmesh->LocalNx), nz(fieldmesh->LocalNz), data(std::move(data_in)) { - TRACE("FieldPerp: Copy constructor from Array and Mesh"); ASSERT1(data.size() == nx * nz); } @@ -97,7 +95,6 @@ FieldPerp& FieldPerp::operator=(const FieldPerp& rhs) { } FieldPerp& FieldPerp::operator=(const BoutReal rhs) { - TRACE("FieldPerp = BoutReal"); allocate(); diff --git a/src/field/vecops.cxx b/src/field/vecops.cxx index 4d62d1a1d7..1677187fcd 100644 --- a/src/field/vecops.cxx +++ b/src/field/vecops.cxx @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -39,7 +38,7 @@ **************************************************************************/ Vector2D Grad(const Field2D& f, CELL_LOC outloc, const std::string& method) { - TRACE("Grad( Field2D )"); + SCOREP0(); CELL_LOC outloc_x, outloc_y, outloc_z; if (outloc == CELL_VSHIFT) { @@ -68,7 +67,7 @@ Vector2D Grad(const Field2D& f, CELL_LOC outloc, const std::string& method) { } Vector3D Grad(const Field3D& f, CELL_LOC outloc, const std::string& method) { - TRACE("Grad( Field3D )"); + SCOREP0(); CELL_LOC outloc_x, outloc_y, outloc_z; if (outloc == CELL_VSHIFT) { @@ -97,7 +96,7 @@ Vector3D Grad(const Field3D& f, CELL_LOC outloc, const std::string& method) { } Vector3D Grad_perp(const Field3D& f, CELL_LOC outloc, const std::string& method) { - TRACE("Grad_perp( Field3D )"); + SCOREP0(); ASSERT1(outloc == CELL_DEFAULT || outloc == f.getLocation()); @@ -145,7 +144,7 @@ Vector2D Grad_perp(const Field2D& f, CELL_LOC outloc, const std::string& method) Coordinates::FieldMetric Div(const Vector2D& v, CELL_LOC outloc, const std::string& method) { - TRACE("Div( Vector2D )"); + SCOREP0(); if (outloc == CELL_DEFAULT) { outloc = v.getLocation(); @@ -170,7 +169,7 @@ Coordinates::FieldMetric Div(const Vector2D& v, CELL_LOC outloc, } Field3D Div(const Vector3D& v, CELL_LOC outloc, const std::string& method) { - TRACE("Div( Vector3D )"); + SCOREP0(); if (outloc == CELL_DEFAULT) { outloc = v.getLocation(); @@ -209,7 +208,7 @@ Field3D Div(const Vector3D& v, CELL_LOC outloc, const std::string& method) { Coordinates::FieldMetric Div(const Vector2D& v, const Field2D& f, CELL_LOC outloc, const std::string& method) { - TRACE("Div( Vector2D, Field2D )"); + SCOREP0(); if (outloc == CELL_DEFAULT) { outloc = v.getLocation(); @@ -236,7 +235,6 @@ Coordinates::FieldMetric Div(const Vector2D& v, const Field2D& f, CELL_LOC outlo Field3D Div(const Vector3D& v, const Field3D& f, CELL_LOC outloc, const std::string& method) { - TRACE("Div( Vector3D, Field3D )"); if (outloc == CELL_DEFAULT) { outloc = v.getLocation(); @@ -265,8 +263,6 @@ Field3D Div(const Vector3D& v, const Field3D& f, CELL_LOC outloc, Vector2D Curl(const Vector2D& v) { - TRACE("Curl( Vector2D )"); - ASSERT1(v.getLocation() != CELL_VSHIFT); Mesh* localmesh = v.getMesh(); auto metric = v.x.getCoordinates(); @@ -292,7 +288,7 @@ Vector2D Curl(const Vector2D& v) { } Vector3D Curl(const Vector3D& v) { - TRACE("Curl( Vector3D )"); + SCOREP0(); ASSERT1(v.getLocation() != CELL_VSHIFT); @@ -323,7 +319,7 @@ Vector3D Curl(const Vector3D& v) { * Upwinding operators **************************************************************************/ Coordinates::FieldMetric V_dot_Grad(const Vector2D& v, const Field2D& f) { - TRACE("V_dot_Grad( Vector2D , Field2D )"); + SCOREP0(); // Get contravariant components of v @@ -334,7 +330,7 @@ Coordinates::FieldMetric V_dot_Grad(const Vector2D& v, const Field2D& f) { } Field3D V_dot_Grad(const Vector2D& v, const Field3D& f) { - TRACE("V_dot_Grad( Vector2D , Field3D )"); + SCOREP0(); // Get contravariant components of v @@ -345,7 +341,7 @@ Field3D V_dot_Grad(const Vector2D& v, const Field3D& f) { } Field3D V_dot_Grad(const Vector3D& v, const Field2D& f) { - TRACE("V_dot_Grad( Vector3D , Field2D )"); + SCOREP0(); // Get contravariant components of v @@ -356,7 +352,7 @@ Field3D V_dot_Grad(const Vector3D& v, const Field2D& f) { } Field3D V_dot_Grad(const Vector3D& v, const Field3D& f) { - TRACE("V_dot_Grad( Vector3D , Field3D )"); + SCOREP0(); // Get contravariant components of v diff --git a/src/field/vector2d.cxx b/src/field/vector2d.cxx index 74d3a88a22..ab2d993549 100644 --- a/src/field/vector2d.cxx +++ b/src/field/vector2d.cxx @@ -429,7 +429,7 @@ CELL_LOC Vector2D::getLocation() const { Vector2D& Vector2D::setLocation(CELL_LOC loc) { SCOREP0(); - TRACE("Vector2D::setLocation"); + if (loc == CELL_DEFAULT) { loc = CELL_CENTRE; } diff --git a/src/field/vector3d.cxx b/src/field/vector3d.cxx index 56124595b3..7fb4a88918 100644 --- a/src/field/vector3d.cxx +++ b/src/field/vector3d.cxx @@ -551,7 +551,7 @@ CELL_LOC Vector3D::getLocation() const { Vector3D& Vector3D::setLocation(CELL_LOC loc) { SCOREP0(); - TRACE("Vector3D::setLocation"); + if (loc == CELL_DEFAULT) { loc = CELL_CENTRE; } diff --git a/src/invert/laplace/impls/cyclic/cyclic_laplace.cxx b/src/invert/laplace/impls/cyclic/cyclic_laplace.cxx index 837ac3755f..99aacea4f8 100644 --- a/src/invert/laplace/impls/cyclic/cyclic_laplace.cxx +++ b/src/invert/laplace/impls/cyclic/cyclic_laplace.cxx @@ -304,7 +304,6 @@ FieldPerp LaplaceCyclic::solve(const FieldPerp& rhs, const FieldPerp& x0) { } Field3D LaplaceCyclic::solve(const Field3D& rhs, const Field3D& x0) { - TRACE("LaplaceCyclic::solve(Field3D, Field3D)"); ASSERT1(rhs.getLocation() == location); ASSERT1(x0.getLocation() == location); diff --git a/src/invert/laplace/impls/iterative_parallel_tri/iterative_parallel_tri.cxx b/src/invert/laplace/impls/iterative_parallel_tri/iterative_parallel_tri.cxx index 5255ea939d..926facd9e6 100644 --- a/src/invert/laplace/impls/iterative_parallel_tri/iterative_parallel_tri.cxx +++ b/src/invert/laplace/impls/iterative_parallel_tri/iterative_parallel_tri.cxx @@ -234,7 +234,6 @@ FieldPerp LaplaceIPT::solve(const FieldPerp& b, const FieldPerp& x0) { ASSERT1(localmesh == b.getMesh() && localmesh == x0.getMesh()); ASSERT1(b.getLocation() == location); ASSERT1(x0.getLocation() == location); - TRACE("LaplaceIPT::solve(const, const)"); FieldPerp x{emptyFrom(b)}; diff --git a/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx b/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx index 04c8c7e0c9..48137a13bf 100644 --- a/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx +++ b/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx @@ -46,8 +46,6 @@ LaplaceMultigrid::LaplaceMultigrid(Options* opt, const CELL_LOC loc, Mesh* mesh_ Solver* UNUSED(solver)) : Laplacian(opt, loc, mesh_in), A(0.0), C1(1.0), C2(1.0), D(1.0) { - TRACE("LaplaceMultigrid::LaplaceMultigrid(Options *opt)"); - // periodic x-direction not handled: see MultigridAlg::communications ASSERT1(!localmesh->periodicX); @@ -223,8 +221,6 @@ LaplaceMultigrid::LaplaceMultigrid(Options* opt, const CELL_LOC loc, Mesh* mesh_ FieldPerp LaplaceMultigrid::solve(const FieldPerp& b_in, const FieldPerp& x0) { - TRACE("LaplaceMultigrid::solve(const FieldPerp, const FieldPerp)"); - ASSERT1(localmesh == b_in.getMesh() && localmesh == x0.getMesh()); ASSERT1(b_in.getLocation() == location); ASSERT1(x0.getLocation() == location); @@ -578,7 +574,6 @@ FieldPerp LaplaceMultigrid::solve(const FieldPerp& b_in, const FieldPerp& x0) { } void LaplaceMultigrid::generateMatrixF(int level) { - TRACE("LaplaceMultigrid::generateMatrixF(int)"); // Set (fine-level) matrix entries diff --git a/src/invert/laplace/impls/pcr/pcr.cxx b/src/invert/laplace/impls/pcr/pcr.cxx index b619d80100..60169c6eb4 100644 --- a/src/invert/laplace/impls/pcr/pcr.cxx +++ b/src/invert/laplace/impls/pcr/pcr.cxx @@ -308,7 +308,6 @@ FieldPerp LaplacePCR::solve(const FieldPerp& rhs, const FieldPerp& x0) { } Field3D LaplacePCR::solve(const Field3D& rhs, const Field3D& x0) { - TRACE("LaplacePCR::solve(Field3D, Field3D)"); ASSERT1(rhs.getLocation() == location); ASSERT1(x0.getLocation() == location); diff --git a/src/invert/laplace/impls/pcr_thomas/pcr_thomas.cxx b/src/invert/laplace/impls/pcr_thomas/pcr_thomas.cxx index b48b20f246..600166aa6b 100644 --- a/src/invert/laplace/impls/pcr_thomas/pcr_thomas.cxx +++ b/src/invert/laplace/impls/pcr_thomas/pcr_thomas.cxx @@ -304,7 +304,6 @@ FieldPerp LaplacePCR_THOMAS::solve(const FieldPerp& rhs, const FieldPerp& x0) { } Field3D LaplacePCR_THOMAS::solve(const Field3D& rhs, const Field3D& x0) { - TRACE("LaplacePCR_THOMAS::solve(Field3D, Field3D)"); ASSERT1(rhs.getLocation() == location); ASSERT1(x0.getLocation() == location); diff --git a/src/invert/laplace/impls/petsc/petsc_laplace.cxx b/src/invert/laplace/impls/petsc/petsc_laplace.cxx index 5f417d4faa..65c80ec48c 100644 --- a/src/invert/laplace/impls/petsc/petsc_laplace.cxx +++ b/src/invert/laplace/impls/petsc/petsc_laplace.cxx @@ -336,7 +336,6 @@ FieldPerp LaplacePetsc::solve(const FieldPerp& b) { return solve(b, b); } * \returns sol The solution x of the problem Ax=b. */ FieldPerp LaplacePetsc::solve(const FieldPerp& b, const FieldPerp& x0) { - TRACE("LaplacePetsc::solve"); ASSERT1(localmesh == b.getMesh() && localmesh == x0.getMesh()); ASSERT1(b.getLocation() == location); diff --git a/src/invert/laplace/invert_laplace.cxx b/src/invert/laplace/invert_laplace.cxx index 7a8af20fbd..b8650d1d68 100644 --- a/src/invert/laplace/invert_laplace.cxx +++ b/src/invert/laplace/invert_laplace.cxx @@ -156,7 +156,6 @@ void Laplacian::cleanup() { instance.reset(); } **********************************************************************************/ Field3D Laplacian::solve(const Field3D& b) { - TRACE("Laplacian::solve(Field3D)"); ASSERT1(b.getLocation() == location); ASSERT1(localmesh == b.getMesh()); @@ -217,7 +216,6 @@ Field2D Laplacian::solve(const Field2D& b) { * \returns x All the y-slices of x_slice in the equation A*x_slice = b_slice */ Field3D Laplacian::solve(const Field3D& b, const Field3D& x0) { - TRACE("Laplacian::solve(Field3D, Field3D)"); ASSERT1(b.getLocation() == location); ASSERT1(x0.getLocation() == location); diff --git a/src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.cxx b/src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.cxx index a242bf3432..1de9d58b26 100644 --- a/src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.cxx +++ b/src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.cxx @@ -61,7 +61,7 @@ LaplaceXZcyclic::LaplaceXZcyclic(Mesh* m, Options* options, const CELL_LOC loc) } void LaplaceXZcyclic::setCoefs(const Field2D& A2D, const Field2D& B2D) { - TRACE("LaplaceXZcyclic::setCoefs"); + Timer timer("invert"); ASSERT1(A2D.getMesh() == localmesh); diff --git a/src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx b/src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx index 769e797352..d81446d522 100644 --- a/src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx +++ b/src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx @@ -97,8 +97,6 @@ LaplaceXZpetsc::LaplaceXZpetsc(Mesh* m, Options* opt, const CELL_LOC loc) * given by b */ - TRACE("LaplaceXZpetsc::LaplaceXZpetsc"); - if (opt == nullptr) { // If no options supplied, use default opt = &(Options::root())["laplacexz"]; @@ -260,8 +258,6 @@ LaplaceXZpetsc::LaplaceXZpetsc(Mesh* m, Options* opt, const CELL_LOC loc) LaplaceXZpetsc::~LaplaceXZpetsc() { - TRACE("LaplaceXZpetsc::~LaplaceXZpetsc"); - PetscBool petsc_is_finalised; PetscFinalized(&petsc_is_finalised); @@ -293,8 +289,6 @@ void LaplaceXZpetsc::setCoefs(const Field3D& Ain, const Field3D& Bin) { * Bin - The B coefficient in div(A grad_perp(B)) + Bf = b */ - TRACE("LaplaceXZpetsc::setCoefs"); - ASSERT1(Ain.getMesh() == localmesh); ASSERT1(Bin.getMesh() == localmesh); ASSERT1(Ain.getLocation() == location); @@ -767,8 +761,6 @@ Field3D LaplaceXZpetsc::solve(const Field3D& bin, const Field3D& x0in) { * result - The solved x (returned as a Field3D) in the matrix problem Ax=b */ - TRACE("LaplaceXZpetsc::solve"); - ASSERT1(bin.getMesh() == localmesh); ASSERT1(x0in.getMesh() == localmesh); ASSERT1(bin.getLocation() == location); diff --git a/src/invert/parderiv/impls/cyclic/cyclic.cxx b/src/invert/parderiv/impls/cyclic/cyclic.cxx index 5a798ca1d5..692d5f2660 100644 --- a/src/invert/parderiv/impls/cyclic/cyclic.cxx +++ b/src/invert/parderiv/impls/cyclic/cyclic.cxx @@ -63,7 +63,7 @@ InvertParCR::InvertParCR(Options* opt, CELL_LOC location, Mesh* mesh_in) } const Field3D InvertParCR::solve(const Field3D& f) { - TRACE("InvertParCR::solve(Field3D)"); + ASSERT1(localmesh == f.getMesh()); ASSERT1(location == f.getLocation()); diff --git a/src/invert/pardiv/impls/cyclic/pardiv_cyclic.cxx b/src/invert/pardiv/impls/cyclic/pardiv_cyclic.cxx index be65d5ab0b..bd644dc625 100644 --- a/src/invert/pardiv/impls/cyclic/pardiv_cyclic.cxx +++ b/src/invert/pardiv/impls/cyclic/pardiv_cyclic.cxx @@ -59,7 +59,7 @@ InvertParDivCR::InvertParDivCR(Options* opt, CELL_LOC location, Mesh* mesh_in) } Field3D InvertParDivCR::solve(const Field3D& f) { - TRACE("InvertParDivCR::solve(Field3D)"); + ASSERT1(localmesh == f.getMesh()); ASSERT1(location == f.getLocation()); diff --git a/src/mesh/boundary_standard.cxx b/src/mesh/boundary_standard.cxx index 5508f8db71..4019fc4eea 100644 --- a/src/mesh/boundary_standard.cxx +++ b/src/mesh/boundary_standard.cxx @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -30,8 +29,6 @@ using bout::generator::Context; */ #if CHECK > 0 void verifyNumPoints(BoundaryRegion* region, int ptsRequired) { - TRACE("Verifying number of points available for BC"); - int ptsAvailGlobal, ptsAvailLocal, ptsAvail; std::string side, gridType; Mesh* mesh = region->localmesh; @@ -3606,7 +3603,6 @@ void BoundaryNeumann_NonOrthogonal::apply(Field3D& f) { } void BoundaryRelax::apply_ddt(Field2D & f) { - TRACE("BoundaryRelax::apply_ddt(Field2D)"); // Make a copy of f Field2D g = f; @@ -3622,7 +3618,6 @@ void BoundaryNeumann_NonOrthogonal::apply(Field3D& f) { } void BoundaryRelax::apply_ddt(Field3D & f) { - TRACE("BoundaryRelax::apply_ddt(Field3D)"); Mesh* mesh = bndry->localmesh; ASSERT1(mesh == f.getMesh()); diff --git a/src/mesh/coordinates.cxx b/src/mesh/coordinates.cxx index 58d54f826e..b275f0c8de 100644 --- a/src/mesh/coordinates.cxx +++ b/src/mesh/coordinates.cxx @@ -932,7 +932,7 @@ const Field2D& Coordinates::zlength() const { int Coordinates::geometry(bool recalculate_staggered, bool force_interpolate_from_centre) { - TRACE("Coordinates::geometry"); + localmesh->communicate_no_slices(dx, dy, dz, g11, g22, g33, g12, g13, g23, g_11, g_22, g_33, g_12, g_13, g_23, J, Bxy); @@ -1202,7 +1202,6 @@ int Coordinates::geometry(bool recalculate_staggered, } int Coordinates::calcCovariant(const std::string& region) { - TRACE("Coordinates::calcCovariant"); // Make sure metric elements are allocated g_11.allocate(); @@ -1265,7 +1264,6 @@ int Coordinates::calcCovariant(const std::string& region) { } int Coordinates::calcContravariant(const std::string& region) { - TRACE("Coordinates::calcContravariant"); // Make sure metric elements are allocated g11.allocate(); @@ -1320,7 +1318,7 @@ int Coordinates::calcContravariant(const std::string& region) { } int Coordinates::jacobian() { - TRACE("Coordinates::jacobian"); + // calculate Jacobian using g^-1 = det[g^ij], J = sqrt(g) const bool extrapolate_x = not localmesh->sourceHasXBoundaryGuards(); @@ -1522,7 +1520,7 @@ Field3D Coordinates::DDZ(const Field3D& f, CELL_LOC outloc, const std::string& m Coordinates::FieldMetric Coordinates::Grad_par(const Field2D& var, [[maybe_unused]] CELL_LOC outloc, const std::string& UNUSED(method)) { - TRACE("Coordinates::Grad_par( Field2D )"); + ASSERT1(location == outloc || (outloc == CELL_DEFAULT && location == var.getLocation())); @@ -1531,7 +1529,7 @@ Coordinates::FieldMetric Coordinates::Grad_par(const Field2D& var, Field3D Coordinates::Grad_par(const Field3D& var, CELL_LOC outloc, const std::string& method) { - TRACE("Coordinates::Grad_par( Field3D )"); + ASSERT1(location == outloc || outloc == CELL_DEFAULT); return ::DDY(var, outloc, method) * invSg(); @@ -1561,7 +1559,7 @@ Field3D Coordinates::Vpar_Grad_par(const Field3D& v, const Field3D& f, CELL_LOC Coordinates::FieldMetric Coordinates::Div_par(const Field2D& f, CELL_LOC outloc, const std::string& method) { - TRACE("Coordinates::Div_par( Field2D )"); + ASSERT1(location == outloc || outloc == CELL_DEFAULT); // Need Bxy at location of f, which might be different from location of this @@ -1573,7 +1571,7 @@ Coordinates::FieldMetric Coordinates::Div_par(const Field2D& f, CELL_LOC outloc, Field3D Coordinates::Div_par(const Field3D& f, CELL_LOC outloc, const std::string& method) { - TRACE("Coordinates::Div_par( Field3D )"); + ASSERT1(location == outloc || outloc == CELL_DEFAULT); // Need Bxy at location of f, which might be different from location of this @@ -1602,7 +1600,7 @@ Field3D Coordinates::Div_par(const Field3D& f, CELL_LOC outloc, Coordinates::FieldMetric Coordinates::Grad2_par2(const Field2D& f, CELL_LOC outloc, const std::string& method) { - TRACE("Coordinates::Grad2_par2( Field2D )"); + ASSERT1(location == outloc || (outloc == CELL_DEFAULT && location == f.getLocation())); auto result = Grad2_par2_DDY_invSg(outloc, method) * DDY(f, outloc, method) @@ -1613,7 +1611,7 @@ Coordinates::FieldMetric Coordinates::Grad2_par2(const Field2D& f, CELL_LOC outl Field3D Coordinates::Grad2_par2(const Field3D& f, CELL_LOC outloc, const std::string& method) { - TRACE("Coordinates::Grad2_par2( Field3D )"); + if (outloc == CELL_DEFAULT) { outloc = f.getLocation(); } @@ -1637,7 +1635,7 @@ Field3D Coordinates::Grad2_par2(const Field3D& f, CELL_LOC outloc, Coordinates::FieldMetric Coordinates::Delp2(const Field2D& f, CELL_LOC outloc, bool UNUSED(useFFT)) { - TRACE("Coordinates::Delp2( Field2D )"); + ASSERT1(location == outloc || outloc == CELL_DEFAULT); auto result = G1 * DDX(f, outloc) + g11 * D2DX2(f, outloc); @@ -1646,7 +1644,6 @@ Coordinates::FieldMetric Coordinates::Delp2(const Field2D& f, CELL_LOC outloc, } Field3D Coordinates::Delp2(const Field3D& f, CELL_LOC outloc, bool useFFT) { - TRACE("Coordinates::Delp2( Field3D )"); if (outloc == CELL_DEFAULT) { outloc = f.getLocation(); @@ -1712,7 +1709,6 @@ Field3D Coordinates::Delp2(const Field3D& f, CELL_LOC outloc, bool useFFT) { } FieldPerp Coordinates::Delp2(const FieldPerp& f, CELL_LOC outloc, bool useFFT) { - TRACE("Coordinates::Delp2( FieldPerp )"); if (outloc == CELL_DEFAULT) { outloc = f.getLocation(); @@ -1789,7 +1785,7 @@ Field3D Coordinates::Laplace_par(const Field3D& f, CELL_LOC outloc) { Coordinates::FieldMetric Coordinates::Laplace(const Field2D& f, CELL_LOC outloc, const std::string& dfdy_boundary_conditions, const std::string& dfdy_dy_region) { - TRACE("Coordinates::Laplace( Field2D )"); + ASSERT1(location == outloc || outloc == CELL_DEFAULT); auto result = G1 * DDX(f, outloc) + G2 * DDY(f, outloc) + g11 * D2DX2(f, outloc) @@ -1804,7 +1800,7 @@ Coordinates::FieldMetric Coordinates::Laplace(const Field2D& f, CELL_LOC outloc, Field3D Coordinates::Laplace(const Field3D& f, CELL_LOC outloc, const std::string& dfdy_boundary_conditions, const std::string& dfdy_dy_region) { - TRACE("Coordinates::Laplace( Field3D )"); + ASSERT1(location == outloc || outloc == CELL_DEFAULT); Field3D result = G1 * ::DDX(f, outloc) + G2 * ::DDY(f, outloc) + G3 * ::DDZ(f, outloc) @@ -1823,7 +1819,7 @@ Field3D Coordinates::Laplace(const Field3D& f, CELL_LOC outloc, // solver Field2D Coordinates::Laplace_perpXY([[maybe_unused]] const Field2D& A, [[maybe_unused]] const Field2D& f) { - TRACE("Coordinates::Laplace_perpXY( Field2D )"); + #if not(BOUT_USE_METRIC_3D) Field2D result; result.allocate(); diff --git a/src/mesh/data/gridfromfile.cxx b/src/mesh/data/gridfromfile.cxx index fba64eaa59..952ea22243 100644 --- a/src/mesh/data/gridfromfile.cxx +++ b/src/mesh/data/gridfromfile.cxx @@ -20,7 +20,6 @@ GridFile::GridFile(std::string gridfilename) : GridDataSource(true), data(bout::OptionsIO::create(gridfilename)->read()), filename(std::move(gridfilename)) { - TRACE("GridFile constructor"); // Get number of y-boundary guard cells saved in the grid file grid_yguards = data["y_boundary_guards"].withDefault(0); @@ -60,7 +59,7 @@ bool GridFile::hasVar(const std::string& name) { return data.isSet(name); } bool GridFile::get(Mesh* UNUSED(m), std::string& sval, const std::string& name, const std::string& def) { Timer timer("io"); - TRACE("GridFile::get(std::string)"); + const bool success = data.isSet(name); if (not success) { // Override any previously set defaults @@ -93,7 +92,7 @@ bool GridFile::get(Mesh* UNUSED(m), std::string& sval, const std::string& name, */ bool GridFile::get(Mesh* UNUSED(m), int& ival, const std::string& name, int def) { Timer timer("io"); - TRACE("GridFile::get(int)"); + const bool success = data.isSet(name); if (not success) { // Override any previously set defaults @@ -110,7 +109,7 @@ bool GridFile::get(Mesh* UNUSED(m), int& ival, const std::string& name, int def) bool GridFile::get(Mesh* UNUSED(m), BoutReal& rval, const std::string& name, BoutReal def) { Timer timer("io"); - TRACE("GridFile::get(BoutReal)"); + const bool success = data.isSet(name); if (not success) { // Override any previously set defaults @@ -472,7 +471,6 @@ bool GridFile::get([[maybe_unused]] Mesh* m, [[maybe_unused]] std::vector& [[maybe_unused]] const std::string& name, [[maybe_unused]] int len, [[maybe_unused]] int offset, [[maybe_unused]] GridDataSource::Direction dir) { - TRACE("GridFile::get(vector)"); if (not data.isSet(name)) { return false; @@ -498,7 +496,6 @@ bool GridFile::get([[maybe_unused]] Mesh* m, [[maybe_unused]] std::vector& bool GridFile::get(Mesh* UNUSED(m), std::vector& var, const std::string& name, int len, int offset, GridDataSource::Direction UNUSED(dir)) { - TRACE("GridFile::get(vector)"); if (not data.isSet(name)) { return false; diff --git a/src/mesh/difops.cxx b/src/mesh/difops.cxx index 42fa4d6ca5..9084f90465 100644 --- a/src/mesh/difops.cxx +++ b/src/mesh/difops.cxx @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -458,8 +457,6 @@ Field2D Laplace_perpXY(const Field2D& A, const Field2D& f) { Coordinates::FieldMetric b0xGrad_dot_Grad(const Field2D& phi, const Field2D& A, CELL_LOC outloc) { - TRACE("b0xGrad_dot_Grad( Field2D , Field2D )"); - if (outloc == CELL_DEFAULT) { outloc = A.getLocation(); } @@ -489,7 +486,6 @@ Coordinates::FieldMetric b0xGrad_dot_Grad(const Field2D& phi, const Field2D& A, } Field3D b0xGrad_dot_Grad(const Field2D& phi, const Field3D& A, CELL_LOC outloc) { - TRACE("b0xGrad_dot_Grad( Field2D , Field3D )"); if (outloc == CELL_DEFAULT) { outloc = A.getLocation(); @@ -531,7 +527,6 @@ Field3D b0xGrad_dot_Grad(const Field2D& phi, const Field3D& A, CELL_LOC outloc) } Field3D b0xGrad_dot_Grad(const Field3D& p, const Field2D& A, CELL_LOC outloc) { - TRACE("b0xGrad_dot_Grad( Field3D , Field2D )"); if (outloc == CELL_DEFAULT) { outloc = A.getLocation(); @@ -566,7 +561,6 @@ Field3D b0xGrad_dot_Grad(const Field3D& p, const Field2D& A, CELL_LOC outloc) { } Field3D b0xGrad_dot_Grad(const Field3D& phi, const Field3D& A, CELL_LOC outloc) { - TRACE("b0xGrad_dot_Grad( Field3D , Field3D )"); if (outloc == CELL_DEFAULT) { outloc = A.getLocation(); @@ -614,7 +608,6 @@ Field3D b0xGrad_dot_Grad(const Field3D& phi, const Field3D& A, CELL_LOC outloc) Coordinates::FieldMetric bracket(const Field2D& f, const Field2D& g, BRACKET_METHOD method, CELL_LOC outloc, Solver* UNUSED(solver)) { - TRACE("bracket(Field2D, Field2D)"); ASSERT1_FIELDS_COMPATIBLE(f, g); if (outloc == CELL_DEFAULT) { @@ -637,7 +630,6 @@ Coordinates::FieldMetric bracket(const Field2D& f, const Field2D& g, Field3D bracket(const Field3D& f, const Field2D& g, BRACKET_METHOD method, CELL_LOC outloc, Solver* solver) { - TRACE("bracket(Field3D, Field2D)"); ASSERT1_FIELDS_COMPATIBLE(f, g); if (outloc == CELL_DEFAULT) { @@ -826,7 +818,6 @@ Field3D bracket(const Field3D& f, const Field2D& g, BRACKET_METHOD method, Field3D bracket(const Field2D& f, const Field3D& g, BRACKET_METHOD method, CELL_LOC outloc, Solver* solver) { - TRACE("bracket(Field2D, Field3D)"); ASSERT1_FIELDS_COMPATIBLE(f, g); if (outloc == CELL_DEFAULT) { @@ -863,8 +854,6 @@ Field3D bracket(const Field2D& f, const Field3D& g, BRACKET_METHOD method, Field3D bracket(const Field3D& f, const Field3D& g, BRACKET_METHOD method, CELL_LOC outloc, [[maybe_unused]] Solver* solver) { - TRACE("Field3D, Field3D"); - ASSERT1_FIELDS_COMPATIBLE(f, g); if (outloc == CELL_DEFAULT) { outloc = g.getLocation(); diff --git a/src/mesh/fv_ops.cxx b/src/mesh/fv_ops.cxx index fe5422b4d1..2f3398b2c0 100644 --- a/src/mesh/fv_ops.cxx +++ b/src/mesh/fv_ops.cxx @@ -181,7 +181,6 @@ Field3D Div_a_Grad_perp(const Field3D& a, const Field3D& f) { const Field3D Div_par_K_Grad_par(const Field3D& Kin, const Field3D& fin, bool bndry_flux) { - TRACE("FV::Div_par_K_Grad_par"); ASSERT2(Kin.getLocation() == fin.getLocation()); diff --git a/src/mesh/impls/bout/boutmesh.cxx b/src/mesh/impls/bout/boutmesh.cxx index 8917fa3753..8eb09f84ec 100644 --- a/src/mesh/impls/bout/boutmesh.cxx +++ b/src/mesh/impls/bout/boutmesh.cxx @@ -431,7 +431,6 @@ void BoutMesh::setDerivedGridSizes() { } int BoutMesh::load() { - TRACE("BoutMesh::load()"); output_progress << _("Loading mesh") << endl; @@ -1363,7 +1362,6 @@ comm_handle BoutMesh::sendY(FieldGroup& g, comm_handle handle) { } int BoutMesh::wait(comm_handle handle) { - TRACE("BoutMesh::wait(comm_handle)"); if (handle == nullptr) { return 1; diff --git a/src/mesh/index_derivs.cxx b/src/mesh/index_derivs.cxx index 595081e3ae..48284c3536 100644 --- a/src/mesh/index_derivs.cxx +++ b/src/mesh/index_derivs.cxx @@ -25,7 +25,6 @@ #include "bout/traits.hxx" #include #include -#include #include /******************************************************************************* @@ -34,7 +33,6 @@ /// Initialise the derivative methods. Must be called before any derivatives are used void Mesh::derivs_init(Options* options) { - TRACE("Initialising derivatives"); // For each direction need to set what the default method is for each type // of derivative. DerivativeStore::getInstance().initialise(options); @@ -45,7 +43,6 @@ void Mesh::derivs_init(Options* options) { STAGGER Mesh::getStagger(const CELL_LOC inloc, const CELL_LOC outloc, const CELL_LOC allowedStaggerLoc) const { - TRACE("Mesh::getStagger -- three arguments"); ASSERT1(outloc == inloc || (outloc == CELL_CENTRE && inloc == allowedStaggerLoc) || (outloc == allowedStaggerLoc && inloc == CELL_CENTRE)); @@ -61,7 +58,6 @@ STAGGER Mesh::getStagger(const CELL_LOC inloc, const CELL_LOC outloc, STAGGER Mesh::getStagger(const CELL_LOC vloc, [[maybe_unused]] const CELL_LOC inloc, const CELL_LOC outloc, const CELL_LOC allowedStaggerLoc) const { - TRACE("Mesh::getStagger -- four arguments"); ASSERT1(inloc == outloc); ASSERT1(vloc == inloc || (vloc == CELL_CENTRE && inloc == allowedStaggerLoc) || (vloc == allowedStaggerLoc && inloc == CELL_CENTRE)); diff --git a/src/mesh/interpolation_xz.cxx b/src/mesh/interpolation_xz.cxx index f7f0b457f2..a58554dc82 100644 --- a/src/mesh/interpolation_xz.cxx +++ b/src/mesh/interpolation_xz.cxx @@ -25,7 +25,6 @@ #include #include -#include #include #include @@ -36,7 +35,6 @@ const char* strLocation(CELL_LOC loc) { return toString(loc).c_str(); } const Field3D interpolate(const Field3D& f, const Field3D& delta_x, const Field3D& delta_z) { - TRACE("Interpolating 3D field"); XZLagrange4pt interpolateMethod{f.getMesh()}; return interpolateMethod.interpolate(f, delta_x, delta_z); } @@ -47,8 +45,6 @@ const Field3D interpolate(const Field2D& f, const Field3D& delta_x, } const Field3D interpolate(const Field2D& f, const Field3D& delta_x) { - TRACE("interpolate(Field2D, Field3D)"); - Mesh* mesh = f.getMesh(); ASSERT1(mesh == delta_x.getMesh()); Field3D result{emptyFrom(delta_x)}; diff --git a/src/mesh/invert3x3.hxx b/src/mesh/invert3x3.hxx index c011f55bf7..746765d913 100644 --- a/src/mesh/invert3x3.hxx +++ b/src/mesh/invert3x3.hxx @@ -37,7 +37,6 @@ /// return. Otherwise, an empty `std::optional` is return namespace bout { inline std::optional invert3x3(Matrix& a) { - TRACE("invert3x3"); // Calculate the first co-factors const BoutReal A = a(1, 1) * a(2, 2) - a(1, 2) * a(2, 1); diff --git a/src/mesh/mesh.cxx b/src/mesh/mesh.cxx index 1d3f3b0dbe..8964a6b797 100644 --- a/src/mesh/mesh.cxx +++ b/src/mesh/mesh.cxx @@ -298,7 +298,6 @@ bool Mesh::sourceHasYBoundaryGuards() { return source->hasYBoundaryGuards(); } **************************************************************************/ void Mesh::communicateXZ(FieldGroup& g) { - TRACE("Mesh::communicate(FieldGroup&)"); // Send data comm_handle h = sendX(g); @@ -308,7 +307,6 @@ void Mesh::communicateXZ(FieldGroup& g) { } void Mesh::communicateYZ(FieldGroup& g) { - TRACE("Mesh::communicate(FieldGroup&)"); // Send data comm_handle h = sendY(g); @@ -325,7 +323,6 @@ void Mesh::communicateYZ(FieldGroup& g) { } void Mesh::communicate(FieldGroup& g) { - TRACE("Mesh::communicate(FieldGroup&)"); if (include_corner_cells) { // Send data in y-direction diff --git a/src/mesh/parallel/fci.cxx b/src/mesh/parallel/fci.cxx index e8d3af1cdb..08e56584e1 100644 --- a/src/mesh/parallel/fci.cxx +++ b/src/mesh/parallel/fci.cxx @@ -251,7 +251,6 @@ FCIMap::FCIMap(Mesh& mesh, const Coordinates::FieldMetric& UNUSED(dy), Options& } Field3D FCIMap::integrate(Field3D& f) const { - TRACE("FCIMap::integrate"); ASSERT1(f.getDirectionY() == YDirectionType::Standard); ASSERT1(&map_mesh == f.getMesh()); @@ -315,7 +314,6 @@ void FCITransform::checkInputGrid() { } void FCITransform::calcParallelSlices(Field3D& f) { - TRACE("FCITransform::calcParallelSlices"); ASSERT1(f.getDirectionY() == YDirectionType::Standard); // Only have forward_map/backward_map for CELL_CENTRE, so can only deal with @@ -333,7 +331,6 @@ void FCITransform::calcParallelSlices(Field3D& f) { } void FCITransform::integrateParallelSlices(Field3D& f) { - TRACE("FCITransform::integrateParallelSlices"); ASSERT1(f.getDirectionY() == YDirectionType::Standard); // Only have forward_map/backward_map for CELL_CENTRE, so can only deal with diff --git a/src/physics/physicsmodel.cxx b/src/physics/physicsmodel.cxx index f4be3bde2a..a1bde18248 100644 --- a/src/physics/physicsmodel.cxx +++ b/src/physics/physicsmodel.cxx @@ -164,7 +164,6 @@ void PhysicsModel::bout_solve(Vector3D& var, const char* name, } int PhysicsModel::postInit(bool restarting) { - TRACE("PhysicsModel::postInit"); if (restarting) { solver->readEvolvingVariablesFromOptions(restart_options); diff --git a/src/physics/smoothing.cxx b/src/physics/smoothing.cxx index d8f7fb8b6b..309fff1542 100644 --- a/src/physics/smoothing.cxx +++ b/src/physics/smoothing.cxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -46,7 +45,6 @@ // Smooth using simple 1-2-1 filter const Field3D smooth_x(const Field3D& f) { - TRACE("smooth_x"); Mesh* mesh = f.getMesh(); Field3D result{emptyFrom(f)}; @@ -76,7 +74,6 @@ const Field3D smooth_x(const Field3D& f) { } const Field3D smooth_y(const Field3D& f) { - TRACE("smooth_y"); Mesh* mesh = f.getMesh(); Field3D result{emptyFrom(f)}; @@ -117,7 +114,6 @@ const Field3D smooth_y(const Field3D& f) { so no processor/branch cuts in X */ const Field2D averageX(const Field2D& f) { - TRACE("averageX(Field2D)"); Mesh* mesh = f.getMesh(); int ngx = mesh->LocalNx; @@ -176,8 +172,6 @@ const Field2D averageX(const Field2D& f) { */ const Field3D averageX(const Field3D& f) { - TRACE("averageX(Field3D)"); - Mesh* mesh = f.getMesh(); int ngx = mesh->LocalNx; @@ -230,8 +224,6 @@ const Field3D averageX(const Field3D& f) { } const Field2D averageY(const Field2D& f) { - TRACE("averageY(Field2D)"); - Mesh* mesh = f.getMesh(); int ngx = mesh->LocalNx; int ngy = mesh->LocalNy; @@ -275,8 +267,6 @@ const Field2D averageY(const Field2D& f) { } const Field3D averageY(const Field3D& f) { - TRACE("averageY(Field3D)"); - Mesh* mesh = f.getMesh(); int ngx = mesh->LocalNx; @@ -431,7 +421,7 @@ void nl_filter(rvec& f, BoutReal w) { } const Field3D nl_filter_x(const Field3D& f, BoutReal w) { - TRACE("nl_filter_x( Field3D )"); + Mesh* mesh = f.getMesh(); Field3D result{emptyFrom(f)}; @@ -453,7 +443,6 @@ const Field3D nl_filter_x(const Field3D& f, BoutReal w) { } const Field3D nl_filter_y(const Field3D& f, BoutReal w) { - TRACE("nl_filter_x( Field3D )"); Mesh* mesh = f.getMesh(); @@ -481,7 +470,6 @@ const Field3D nl_filter_y(const Field3D& f, BoutReal w) { } const Field3D nl_filter_z(const Field3D& fs, BoutReal w) { - TRACE("nl_filter_z( Field3D )"); Mesh* mesh = fs.getMesh(); Field3D result{emptyFrom(fs)}; diff --git a/src/physics/sourcex.cxx b/src/physics/sourcex.cxx index 1cfc2fdc6e..b3244a4109 100644 --- a/src/physics/sourcex.cxx +++ b/src/physics/sourcex.cxx @@ -77,7 +77,6 @@ const Field3D sink_tanhx(const Field2D& UNUSED(f0), const Field3D& f, BoutReal s // create radial buffer zones to set jpar zero near radial boundaries const Field3D mask_x(const Field3D& f, bool UNUSED(BoutRealspace)) { - TRACE("mask_x"); Mesh* localmesh = f.getMesh(); @@ -101,7 +100,6 @@ const Field3D mask_x(const Field3D& f, bool UNUSED(BoutRealspace)) { // create radial buffer zones to set jpar zero near radial boundaries const Field3D sink_tanhxl(const Field2D& UNUSED(f0), const Field3D& f, BoutReal swidth, BoutReal slength, bool UNUSED(BoutRealspace)) { - TRACE("sink_tanhx"); Mesh* localmesh = f.getMesh(); @@ -123,7 +121,6 @@ const Field3D sink_tanhxl(const Field2D& UNUSED(f0), const Field3D& f, BoutReal // create radial buffer zones to set jpar zero near radial boundaries const Field3D sink_tanhxr(const Field2D& UNUSED(f0), const Field3D& f, BoutReal swidth, BoutReal slength, bool UNUSED(BoutRealspace)) { - TRACE("sink_tanhxr"); Mesh* localmesh = f.getMesh(); @@ -144,7 +141,6 @@ const Field3D sink_tanhxr(const Field2D& UNUSED(f0), const Field3D& f, BoutReal // create radial buffer zones to damp Psi to zero near radial boundaries const Field3D buff_x(const Field3D& f, bool UNUSED(BoutRealspace)) { - TRACE("buff_x"); Mesh* localmesh = f.getMesh(); diff --git a/src/solver/impls/adams_bashforth/adams_bashforth.cxx b/src/solver/impls/adams_bashforth/adams_bashforth.cxx index bb81e3d53f..f911e0045a 100644 --- a/src/solver/impls/adams_bashforth/adams_bashforth.cxx +++ b/src/solver/impls/adams_bashforth/adams_bashforth.cxx @@ -304,8 +304,6 @@ void AdamsBashforthSolver::setMaxTimestep(BoutReal dt) { int AdamsBashforthSolver::init() { - TRACE("Initialising AdamsBashforth solver"); - Solver::init(); output << "\n\tAdams-Bashforth (explicit) multistep solver\n"; diff --git a/src/solver/impls/arkode/arkode.cxx b/src/solver/impls/arkode/arkode.cxx index 0151f90167..804e67a803 100644 --- a/src/solver/impls/arkode/arkode.cxx +++ b/src/solver/impls/arkode/arkode.cxx @@ -188,7 +188,6 @@ ArkodeSolver::~ArkodeSolver() { **************************************************************************/ int ArkodeSolver::init() { - TRACE("Initialising ARKODE solver"); Solver::init(); @@ -507,8 +506,6 @@ int ArkodeSolver::init() { **************************************************************************/ int ArkodeSolver::run() { - TRACE("ArkodeSolver::run()"); - if (!initialised) { throw BoutException("ArkodeSolver not initialised\n"); } diff --git a/src/solver/impls/cvode/cvode.cxx b/src/solver/impls/cvode/cvode.cxx index 8b81a66f6d..4f72e65933 100644 --- a/src/solver/impls/cvode/cvode.cxx +++ b/src/solver/impls/cvode/cvode.cxx @@ -177,7 +177,6 @@ CvodeSolver::~CvodeSolver() { **************************************************************************/ int CvodeSolver::init() { - TRACE("Initialising CVODE solver"); Solver::init(); @@ -346,7 +345,6 @@ int CvodeSolver::init() { } } else { output_info.write("\tUsing Newton iteration\n"); - TRACE("Setting preconditioner"); const auto prectype = use_precon ? (rightprec ? SUN_PREC_RIGHT : SUN_PREC_LEFT) : SUN_PREC_NONE; @@ -486,7 +484,6 @@ CvodeSolver::create_constraints(const std::vector>& fields) { **************************************************************************/ int CvodeSolver::run() { - TRACE("CvodeSolver::run()"); if (!cvode_initialised) { throw BoutException("CvodeSolver not initialised\n"); @@ -814,7 +811,7 @@ void CvodeSolver::loop_vector_option_values_op(Ind2D UNUSED(i2d), BoutReal* opti } void CvodeSolver::resetInternalFields() { - TRACE("CvodeSolver::resetInternalFields"); + save_vars(N_VGetArrayPointer(uvec)); if (CVodeReInit(cvode_mem, simtime, uvec) != CV_SUCCESS) { diff --git a/src/solver/impls/euler/euler.cxx b/src/solver/impls/euler/euler.cxx index 3976f4402c..7e31576a3f 100644 --- a/src/solver/impls/euler/euler.cxx +++ b/src/solver/impls/euler/euler.cxx @@ -33,7 +33,6 @@ void EulerSolver::setMaxTimestep(BoutReal dt) { } int EulerSolver::init() { - TRACE("Initialising Euler solver"); Solver::init(); @@ -63,7 +62,6 @@ int EulerSolver::init() { } int EulerSolver::run() { - TRACE("EulerSolver::run()"); for (int s = 0; s < getNumberOutputSteps(); s++) { BoutReal target = simtime + getOutputTimestep(); diff --git a/src/solver/impls/ida/ida.cxx b/src/solver/impls/ida/ida.cxx index e0354e8b57..84a0bd4abd 100644 --- a/src/solver/impls/ida/ida.cxx +++ b/src/solver/impls/ida/ida.cxx @@ -100,8 +100,6 @@ IdaSolver::~IdaSolver() { int IdaSolver::init() { - TRACE("Initialising IDA solver"); - Solver::init(); output.write("Initialising IDA solver\n"); @@ -233,7 +231,6 @@ int IdaSolver::init() { **************************************************************************/ int IdaSolver::run() { - TRACE("IDA IdaSolver::run()"); if (!initialised) { throw BoutException("IdaSolver not initialised\n"); diff --git a/src/solver/impls/imex-bdf2/imex-bdf2.cxx b/src/solver/impls/imex-bdf2/imex-bdf2.cxx index 07188110ab..f18550ed80 100644 --- a/src/solver/impls/imex-bdf2/imex-bdf2.cxx +++ b/src/solver/impls/imex-bdf2/imex-bdf2.cxx @@ -136,8 +136,6 @@ static PetscErrorCode imexbdf2PCapply(PC pc, Vec x, Vec y) { */ int IMEXBDF2::init() { - TRACE("Initialising IMEX-BDF2 solver"); - Solver::init(); output << "\n\tIMEX-BDF2 time-integration solver\n"; @@ -741,7 +739,6 @@ void IMEXBDF2::constructSNES(SNES* snesIn) { } int IMEXBDF2::run() { - TRACE("IMEXBDF2::run()"); // Multi-step scheme, so first steps are different int order = 1; diff --git a/src/solver/impls/petsc/petsc.cxx b/src/solver/impls/petsc/petsc.cxx index d0535f069d..41e43c31ed 100644 --- a/src/solver/impls/petsc/petsc.cxx +++ b/src/solver/impls/petsc/petsc.cxx @@ -325,8 +325,6 @@ PetscSolver::~PetscSolver() { int PetscSolver::init() { - TRACE("Initialising PETSc-dev solver"); - Solver::init(); int nlocal = getLocalN(); // Number of evolving variables on this processor @@ -970,7 +968,6 @@ PetscErrorCode PetscSolver::formFunction(Vec U, Vec F) { // Matrix-free preconditioner function PetscErrorCode PetscSolver::pre(Vec x, Vec y) { - TRACE("PetscSolver::pre()"); BoutReal* data; diff --git a/src/solver/impls/power/power.cxx b/src/solver/impls/power/power.cxx index 888338b94c..486129562d 100644 --- a/src/solver/impls/power/power.cxx +++ b/src/solver/impls/power/power.cxx @@ -15,7 +15,6 @@ PowerSolver::PowerSolver(Options* opts) curtime((*options)["curtime"].doc("Simulation time (fixed)").withDefault(0.0)) {} int PowerSolver::init() { - TRACE("Initialising Power solver"); Solver::init(); output << "\n\tPower eigenvalue solver\n"; @@ -44,7 +43,6 @@ int PowerSolver::init() { } int PowerSolver::run() { - TRACE("PowerSolver::run()"); // Make sure that f0 has a norm of 1 divide(f0, norm(f0)); diff --git a/src/solver/impls/pvode/pvode.cxx b/src/solver/impls/pvode/pvode.cxx index 63d3c11753..cb6e81d80a 100644 --- a/src/solver/impls/pvode/pvode.cxx +++ b/src/solver/impls/pvode/pvode.cxx @@ -90,7 +90,6 @@ PvodeSolver::~PvodeSolver() { **************************************************************************/ int PvodeSolver::init() { - TRACE("Initialising PVODE solver"); int mudq, mldq, mukeep, mlkeep; boole optIn; @@ -218,7 +217,6 @@ int PvodeSolver::init() { **************************************************************************/ int PvodeSolver::run() { - TRACE("PvodeSolver::run()"); if (!pvode_initialised) { throw BoutException("PvodeSolver not initialised\n"); diff --git a/src/solver/impls/rk3-ssp/rk3-ssp.cxx b/src/solver/impls/rk3-ssp/rk3-ssp.cxx index e13d996c00..14a3c3b0f9 100644 --- a/src/solver/impls/rk3-ssp/rk3-ssp.cxx +++ b/src/solver/impls/rk3-ssp/rk3-ssp.cxx @@ -28,7 +28,6 @@ void RK3SSP::setMaxTimestep(BoutReal dt) { } int RK3SSP::init() { - TRACE("Initialising RK3 SSP solver"); Solver::init(); output << "\n\tRunge-Kutta 3rd-order SSP solver\n"; @@ -63,7 +62,6 @@ int RK3SSP::init() { } int RK3SSP::run() { - TRACE("RK3SSP::run()"); for (int s = 0; s < getNumberOutputSteps(); s++) { BoutReal target = simtime + getOutputTimestep(); diff --git a/src/solver/impls/rk4/rk4.cxx b/src/solver/impls/rk4/rk4.cxx index 0e7a942a45..ca77f3fc77 100644 --- a/src/solver/impls/rk4/rk4.cxx +++ b/src/solver/impls/rk4/rk4.cxx @@ -39,8 +39,6 @@ void RK4Solver::setMaxTimestep(BoutReal dt) { int RK4Solver::init() { - TRACE("Initialising RK4 solver"); - Solver::init(); output << "\n\tRunge-Kutta 4th-order solver\n"; @@ -77,8 +75,6 @@ int RK4Solver::init() { } int RK4Solver::run() { - TRACE("RK4Solver::run()"); - for (int s = 0; s < getNumberOutputSteps(); s++) { BoutReal target = simtime + getOutputTimestep(); diff --git a/src/solver/impls/rkgeneric/rkgeneric.cxx b/src/solver/impls/rkgeneric/rkgeneric.cxx index 1c332d26de..c5d4ea35e7 100644 --- a/src/solver/impls/rkgeneric/rkgeneric.cxx +++ b/src/solver/impls/rkgeneric/rkgeneric.cxx @@ -40,8 +40,6 @@ void RKGenericSolver::setMaxTimestep(BoutReal dt) { int RKGenericSolver::init() { - TRACE("Initialising RKGeneric solver"); - Solver::init(); output << "\n\tRunge-Kutta generic solver with scheme type " << scheme->getType() << "\n"; @@ -86,8 +84,6 @@ void RKGenericSolver::resetInternalFields() { } int RKGenericSolver::run() { - TRACE("RKGenericSolver::run()"); - for (int s = 0; s < getNumberOutputSteps(); s++) { BoutReal target = simtime + getOutputTimestep(); diff --git a/src/solver/impls/slepc/slepc.cxx b/src/solver/impls/slepc/slepc.cxx index 13657a4553..d2eef6d59f 100644 --- a/src/solver/impls/slepc/slepc.cxx +++ b/src/solver/impls/slepc/slepc.cxx @@ -241,8 +241,6 @@ SlepcSolver::~SlepcSolver() { int SlepcSolver::init() { - TRACE("Initialising SLEPc solver"); - // Report initialisation output.write("Initialising SLEPc solver\n"); if (selfSolve) { diff --git a/src/solver/impls/snes/snes.cxx b/src/solver/impls/snes/snes.cxx index 311bc371fe..05c3cbdc5c 100644 --- a/src/solver/impls/snes/snes.cxx +++ b/src/solver/impls/snes/snes.cxx @@ -607,9 +607,6 @@ SNESSolver::SNESSolver(Options* opts) .withDefault(false)) {} int SNESSolver::init() { - - TRACE("Initialising SNES solver"); - Solver::init(); output << "\n\tSNES steady state solver\n"; @@ -829,8 +826,6 @@ int SNESSolver::init() { } int SNESSolver::run() { - TRACE("SNESSolver::run()"); - // Set initial guess at the solution from variables { BoutReal* xdata = nullptr; diff --git a/src/solver/solver.cxx b/src/solver/solver.cxx index ea7866051b..ac3d632419 100644 --- a/src/solver/solver.cxx +++ b/src/solver/solver.cxx @@ -664,9 +664,6 @@ void Solver::writeToModelOutputFile(const Options& options) { **************************************************************************/ int Solver::init() { - - TRACE("Solver::init()"); - if (initialised) { throw BoutException(_("ERROR: Solver is already initialised\n")); } diff --git a/src/sys/options.cxx b/src/sys/options.cxx index 077b2a6d85..bb4c920b90 100644 --- a/src/sys/options.cxx +++ b/src/sys/options.cxx @@ -106,8 +106,6 @@ Options::Options(InitializerList values, Options* parent_instance, } Options& Options::operator[](const std::string& name) { - TRACE("Options::operator[]"); - if (isValue()) { throw BoutException(_("Trying to index Option '{0}' with '{1}', but '{0}' is a " "value, not a section.\n" @@ -145,8 +143,6 @@ Options& Options::operator[](const std::string& name) { } const Options& Options::operator[](const std::string& name) const { - TRACE("Options::operator[] const"); - if (isValue()) { throw BoutException(_("Trying to index Option '{0}' with '{1}', but '{0}' is a " "value, not a section.\n" diff --git a/src/sys/options/options_ini.cxx b/src/sys/options/options_ini.cxx index d1889f993b..939e100f1b 100644 --- a/src/sys/options/options_ini.cxx +++ b/src/sys/options/options_ini.cxx @@ -50,12 +50,10 @@ **************************************************************************/ #include "options_ini.hxx" + #include -#include #include -#include - using namespace std; /************************************************************************** @@ -151,8 +149,6 @@ void OptionINI::read(Options* options, const string& filename) { } void OptionINI::write(Options* options, const std::string& filename) { - TRACE("OptionsINI::write"); - std::ofstream fout; fout.open(filename, ios::out | ios::trunc); diff --git a/src/sys/optionsreader.cxx b/src/sys/optionsreader.cxx index 8624f646df..e16df31c97 100644 --- a/src/sys/optionsreader.cxx +++ b/src/sys/optionsreader.cxx @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -23,7 +22,6 @@ OptionsReader* OptionsReader::getInstance() { } void OptionsReader::read(Options* options, const std::string& filename) { - TRACE("OptionsReader::read"); if (filename.empty()) { throw BoutException("OptionsReader::read passed empty filename\n"); } @@ -34,7 +32,6 @@ void OptionsReader::read(Options* options, const std::string& filename) { } void OptionsReader::write(Options* options, const std::string& filename) { - TRACE("OptionsReader::write"); if (filename.empty()) { throw BoutException("OptionsReader::write passed empty filename\n"); } diff --git a/tests/integrated/test-invertable-operator/invertable_operator.cxx b/tests/integrated/test-invertable-operator/invertable_operator.cxx index 3c99c3dbbd..9f00fad304 100644 --- a/tests/integrated/test-invertable-operator/invertable_operator.cxx +++ b/tests/integrated/test-invertable-operator/invertable_operator.cxx @@ -1,5 +1,4 @@ #include -#include #include #include @@ -16,7 +15,7 @@ class InvertableOperatorTest : public PhysicsModel { // Drop C term for now Field3D operator()(const Field3D& input) { - TRACE("myLaplacian::operator()"); + Field3D result = A * input + D * Delp2(input); // Ensure boundary points are set appropriately as given by the input field. diff --git a/tests/integrated/test-vec/testVec.cxx b/tests/integrated/test-vec/testVec.cxx index bd0e5f2b80..905ffac01a 100644 --- a/tests/integrated/test-vec/testVec.cxx +++ b/tests/integrated/test-vec/testVec.cxx @@ -14,13 +14,11 @@ class VecTest : public PhysicsModel { }; int VecTest::init(bool UNUSED(restarting)) { - TRACE("Halt in VecTest::init"); SOLVE_FOR(n); return 0; } int VecTest::rhs(BoutReal UNUSED(t)) { - TRACE("Halt in VecTest::rhs"); mesh->communicate(n); gradPerpN = Grad_perp(n); mesh->communicate(gradPerpN); From 63e78ae3738fa89ee2b4ac9f309805c296ff906c Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 15:56:59 +0000 Subject: [PATCH 11/34] Fix unnecessary includes of `msg_stack.hxx` --- examples/elm-pb-outerloop/elm_pb_outerloop.cxx | 1 - examples/elm-pb/elm_pb.cxx | 1 - include/bout/bout_enum_class.hxx | 9 ++++----- include/bout/deriv_store.hxx | 1 - include/bout/field.hxx | 2 -- include/bout/index_derivs.hxx | 1 - include/bout/mask.hxx | 1 - include/bout/sys/timer.hxx | 1 - include/bout/utils.hxx | 1 - src/field/field.cxx | 1 - src/field/initialprofiles.cxx | 1 - src/invert/laplace/impls/multigrid/multigrid_laplace.cxx | 1 - src/invert/laplace/invert_laplace.cxx | 1 - src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.cxx | 1 - src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx | 4 +--- src/invert/parderiv/impls/cyclic/cyclic.cxx | 4 +--- src/invert/pardiv/impls/cyclic/pardiv_cyclic.cxx | 1 - src/mesh/coordinates.cxx | 1 - src/mesh/data/gridfromfile.cxx | 1 - src/mesh/fv_ops.cxx | 1 - src/physics/sourcex.cxx | 8 +++----- src/solver/impls/adams_bashforth/adams_bashforth.cxx | 4 +--- src/solver/impls/euler/euler.cxx | 6 +----- src/solver/impls/imex-bdf2/imex-bdf2.cxx | 1 - src/solver/impls/power/power.cxx | 4 +--- src/solver/impls/rk3-ssp/rk3-ssp.cxx | 2 -- src/solver/impls/rk4/rk4.cxx | 4 +--- src/solver/impls/rkgeneric/rkgeneric.cxx | 6 +----- src/solver/impls/slepc/slepc.cxx | 1 - src/solver/impls/snes/snes.cxx | 6 ++---- src/sys/bout_types.cxx | 2 +- src/sys/derivs.cxx | 8 ++------ src/sys/timer.cxx | 2 ++ tests/integrated/test-backtrace/boutexcept.cxx | 1 - 34 files changed, 21 insertions(+), 69 deletions(-) diff --git a/examples/elm-pb-outerloop/elm_pb_outerloop.cxx b/examples/elm-pb-outerloop/elm_pb_outerloop.cxx index 4ff8e90dcb..3cc5227b30 100644 --- a/examples/elm-pb-outerloop/elm_pb_outerloop.cxx +++ b/examples/elm-pb-outerloop/elm_pb_outerloop.cxx @@ -39,7 +39,6 @@ #include #include #include -#include #include #include // Defines BOUT_FOR_RAJA #include diff --git a/examples/elm-pb/elm_pb.cxx b/examples/elm-pb/elm_pb.cxx index fe18a756ae..643f36f5bb 100644 --- a/examples/elm-pb/elm_pb.cxx +++ b/examples/elm-pb/elm_pb.cxx @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/include/bout/bout_enum_class.hxx b/include/bout/bout_enum_class.hxx index 07140220a4..fa4abc8090 100644 --- a/include/bout/bout_enum_class.hxx +++ b/include/bout/bout_enum_class.hxx @@ -22,13 +22,12 @@ #ifndef BOUT_ENUM_CLASS_H #define BOUT_ENUM_CLASS_H -#include "bout/boutexception.hxx" +#include "bout/boutexception.hxx" // IWYU pragma: keep #include "bout/macro_for_each.hxx" -#include "bout/msg_stack.hxx" -#include "bout/options.hxx" +#include "bout/options.hxx" // IWYU pragma: keep -#include -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep /// Create some macro magic similar to bout/macro_for_each.hxx, but allowing for the enum /// class name to be passed through to each _call diff --git a/include/bout/deriv_store.hxx b/include/bout/deriv_store.hxx index 866ac558e5..0e03d6a32e 100644 --- a/include/bout/deriv_store.hxx +++ b/include/bout/deriv_store.hxx @@ -38,7 +38,6 @@ #include #include -#include #include /// Here we have a templated singleton that is used to store DerivativeFunctions diff --git a/include/bout/field.hxx b/include/bout/field.hxx index 35ce42716d..4e41aa3632 100644 --- a/include/bout/field.hxx +++ b/include/bout/field.hxx @@ -30,14 +30,12 @@ class Field; #define FIELD_H #include -#include #include #include "bout/bout_types.hxx" #include "bout/boutcomm.hxx" #include "bout/boutexception.hxx" #include "bout/field_data.hxx" -#include "bout/msg_stack.hxx" #include "bout/region.hxx" #include "bout/traits.hxx" #include "bout/utils.hxx" diff --git a/include/bout/index_derivs.hxx b/include/bout/index_derivs.hxx index 7c2be52ded..ccce9a7f5e 100644 --- a/include/bout/index_derivs.hxx +++ b/include/bout/index_derivs.hxx @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/include/bout/mask.hxx b/include/bout/mask.hxx index fd90ae7345..fc5f814676 100644 --- a/include/bout/mask.hxx +++ b/include/bout/mask.hxx @@ -26,7 +26,6 @@ #include "bout/globals.hxx" #include "bout/mesh.hxx" -#include "bout/msg_stack.hxx" /** * 3D array of bools to mask Field3Ds diff --git a/include/bout/sys/timer.hxx b/include/bout/sys/timer.hxx index 90fd632f62..c6a0c9020a 100644 --- a/include/bout/sys/timer.hxx +++ b/include/bout/sys/timer.hxx @@ -7,7 +7,6 @@ #include #include "bout/msg_stack.hxx" -#include "bout/output.hxx" /*! * Timing class for performance benchmarking and diagnosis diff --git a/include/bout/utils.hxx b/include/bout/utils.hxx index f8d6f08856..04aa0b281d 100644 --- a/include/bout/utils.hxx +++ b/include/bout/utils.hxx @@ -35,7 +35,6 @@ #include "bout/assert.hxx" #include "bout/bout_types.hxx" #include "bout/boutexception.hxx" -#include "bout/msg_stack.hxx" #include "bout/region.hxx" #include "bout/unused.hxx" diff --git a/src/field/field.cxx b/src/field/field.cxx index 797df6c405..e9b01f0bcb 100644 --- a/src/field/field.cxx +++ b/src/field/field.cxx @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/src/field/initialprofiles.cxx b/src/field/initialprofiles.cxx index 5e96d6005a..2c34caa6e1 100644 --- a/src/field/initialprofiles.cxx +++ b/src/field/initialprofiles.cxx @@ -42,7 +42,6 @@ #include #include #include -#include void initial_profile(const std::string& name, Field3D& var) { diff --git a/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx b/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx index 48137a13bf..4be5bfbad3 100644 --- a/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx +++ b/src/invert/laplace/impls/multigrid/multigrid_laplace.cxx @@ -33,7 +33,6 @@ #if not BOUT_USE_METRIC_3D #include -#include #include #if BOUT_USE_OPENMP diff --git a/src/invert/laplace/invert_laplace.cxx b/src/invert/laplace/invert_laplace.cxx index b8650d1d68..e96248ef7e 100644 --- a/src/invert/laplace/invert_laplace.cxx +++ b/src/invert/laplace/invert_laplace.cxx @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.cxx b/src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.cxx index 1de9d58b26..dc987edc75 100644 --- a/src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.cxx +++ b/src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.cxx @@ -5,7 +5,6 @@ #include #include -#include #include #include diff --git a/src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx b/src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx index d81446d522..be23d8d014 100644 --- a/src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx +++ b/src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx @@ -15,10 +15,8 @@ #if BOUT_HAS_PETSC // Requires PETSc #include -#include - -#include #include +#include LaplaceXZpetsc::LaplaceXZpetsc(Mesh* m, Options* opt, const CELL_LOC loc) : LaplaceXZ(m, opt, loc), lib(opt == nullptr ? &(Options::root()["laplacexz"]) : opt), diff --git a/src/invert/parderiv/impls/cyclic/cyclic.cxx b/src/invert/parderiv/impls/cyclic/cyclic.cxx index 692d5f2660..61d23be823 100644 --- a/src/invert/parderiv/impls/cyclic/cyclic.cxx +++ b/src/invert/parderiv/impls/cyclic/cyclic.cxx @@ -46,10 +46,8 @@ #include #include #include -#include -#include - #include +#include #include diff --git a/src/invert/pardiv/impls/cyclic/pardiv_cyclic.cxx b/src/invert/pardiv/impls/cyclic/pardiv_cyclic.cxx index bd644dc625..d4e773f017 100644 --- a/src/invert/pardiv/impls/cyclic/pardiv_cyclic.cxx +++ b/src/invert/pardiv/impls/cyclic/pardiv_cyclic.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/src/mesh/coordinates.cxx b/src/mesh/coordinates.cxx index b275f0c8de..8453a5205f 100644 --- a/src/mesh/coordinates.cxx +++ b/src/mesh/coordinates.cxx @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mesh/data/gridfromfile.cxx b/src/mesh/data/gridfromfile.cxx index 952ea22243..10f6f6926e 100644 --- a/src/mesh/data/gridfromfile.cxx +++ b/src/mesh/data/gridfromfile.cxx @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mesh/fv_ops.cxx b/src/mesh/fv_ops.cxx index 2f3398b2c0..a0a6e1d3c1 100644 --- a/src/mesh/fv_ops.cxx +++ b/src/mesh/fv_ops.cxx @@ -1,6 +1,5 @@ #include #include -#include #include #include diff --git a/src/physics/sourcex.cxx b/src/physics/sourcex.cxx index b3244a4109..659abbf409 100644 --- a/src/physics/sourcex.cxx +++ b/src/physics/sourcex.cxx @@ -2,15 +2,13 @@ * radial source and mask operators **************************************************************/ -#include -#include - #include +#include #include -#include #include +#include -#include "bout/unused.hxx" +#include BoutReal TanH(BoutReal a) { BoutReal temp = exp(a); diff --git a/src/solver/impls/adams_bashforth/adams_bashforth.cxx b/src/solver/impls/adams_bashforth/adams_bashforth.cxx index f911e0045a..72748fd52e 100644 --- a/src/solver/impls/adams_bashforth/adams_bashforth.cxx +++ b/src/solver/impls/adams_bashforth/adams_bashforth.cxx @@ -4,10 +4,8 @@ #include #include -#include -#include - #include +#include #include diff --git a/src/solver/impls/euler/euler.cxx b/src/solver/impls/euler/euler.cxx index 7e31576a3f..2a9e5813f2 100644 --- a/src/solver/impls/euler/euler.cxx +++ b/src/solver/impls/euler/euler.cxx @@ -3,13 +3,9 @@ #include #include -#include #include -#include - -#include - #include +#include EulerSolver::EulerSolver(Options* options) : Solver(options), mxstep((*options)["mxstep"] diff --git a/src/solver/impls/imex-bdf2/imex-bdf2.cxx b/src/solver/impls/imex-bdf2/imex-bdf2.cxx index f18550ed80..062979b59a 100644 --- a/src/solver/impls/imex-bdf2/imex-bdf2.cxx +++ b/src/solver/impls/imex-bdf2/imex-bdf2.cxx @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/src/solver/impls/power/power.cxx b/src/solver/impls/power/power.cxx index 486129562d..5dfccfedda 100644 --- a/src/solver/impls/power/power.cxx +++ b/src/solver/impls/power/power.cxx @@ -3,13 +3,11 @@ #include "power.hxx" #include -#include +#include #include #include -#include - PowerSolver::PowerSolver(Options* opts) : Solver(opts), curtime((*options)["curtime"].doc("Simulation time (fixed)").withDefault(0.0)) {} diff --git a/src/solver/impls/rk3-ssp/rk3-ssp.cxx b/src/solver/impls/rk3-ssp/rk3-ssp.cxx index 14a3c3b0f9..7c00d44b34 100644 --- a/src/solver/impls/rk3-ssp/rk3-ssp.cxx +++ b/src/solver/impls/rk3-ssp/rk3-ssp.cxx @@ -3,10 +3,8 @@ #include #include -#include #include #include -#include #include diff --git a/src/solver/impls/rk4/rk4.cxx b/src/solver/impls/rk4/rk4.cxx index ca77f3fc77..35b3cc2268 100644 --- a/src/solver/impls/rk4/rk4.cxx +++ b/src/solver/impls/rk4/rk4.cxx @@ -3,14 +3,12 @@ #include #include -#include #include +#include #include #include -#include - RK4Solver::RK4Solver(Options* opts) : Solver(opts), atol((*options)["atol"].doc("Absolute tolerance").withDefault(1.e-5)), rtol((*options)["rtol"].doc("Relative tolerance").withDefault(1.e-3)), diff --git a/src/solver/impls/rkgeneric/rkgeneric.cxx b/src/solver/impls/rkgeneric/rkgeneric.cxx index c5d4ea35e7..edf8ed50e3 100644 --- a/src/solver/impls/rkgeneric/rkgeneric.cxx +++ b/src/solver/impls/rkgeneric/rkgeneric.cxx @@ -4,12 +4,8 @@ #include #include -#include -#include - -#include - #include +#include RKGenericSolver::RKGenericSolver(Options* opts) : Solver(opts), atol((*options)["atol"].doc("Absolute tolerance").withDefault(1.e-5)), diff --git a/src/solver/impls/slepc/slepc.cxx b/src/solver/impls/slepc/slepc.cxx index d2eef6d59f..2c52cb3b38 100644 --- a/src/solver/impls/slepc/slepc.cxx +++ b/src/solver/impls/slepc/slepc.cxx @@ -31,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/src/solver/impls/snes/snes.cxx b/src/solver/impls/snes/snes.cxx index 05c3cbdc5c..e1ef477105 100644 --- a/src/solver/impls/snes/snes.cxx +++ b/src/solver/impls/snes/snes.cxx @@ -1,4 +1,4 @@ -#include "bout/build_config.hxx" +#include "bout/build_defines.hxx" #if BOUT_HAS_PETSC @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -18,8 +18,6 @@ #include #include -#include - #include "petscerror.h" #include "petscmat.h" #include "petscpc.h" diff --git a/src/sys/bout_types.cxx b/src/sys/bout_types.cxx index f5e971af78..b27fab7ae7 100644 --- a/src/sys/bout_types.cxx +++ b/src/sys/bout_types.cxx @@ -1,6 +1,6 @@ #include #include -#include + #include namespace { diff --git a/src/sys/derivs.cxx b/src/sys/derivs.cxx index ed036fffd4..13be388e97 100644 --- a/src/sys/derivs.cxx +++ b/src/sys/derivs.cxx @@ -44,14 +44,10 @@ #include #include #include -#include -#include -#include - -#include - #include +#include #include +#include /******************************************************************************* * First central derivatives diff --git a/src/sys/timer.cxx b/src/sys/timer.cxx index 314d599905..410cffad94 100644 --- a/src/sys/timer.cxx +++ b/src/sys/timer.cxx @@ -1,5 +1,7 @@ #include "bout/sys/timer.hxx" +#include + #include #include diff --git a/tests/integrated/test-backtrace/boutexcept.cxx b/tests/integrated/test-backtrace/boutexcept.cxx index ed33a4c018..70bf480862 100644 --- a/tests/integrated/test-backtrace/boutexcept.cxx +++ b/tests/integrated/test-backtrace/boutexcept.cxx @@ -1,5 +1,4 @@ #include "bout/boutexception.hxx" -#include "bout/msg_stack.hxx" void troublemaker() { throw BoutException("test"); } void f() { troublemaker(); } From c42afa3bd3de747bd1daf3a63dede907112e5fa8 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 16:37:07 +0000 Subject: [PATCH 12/34] Don't duplicate exception message when thrown from `BoutInitialise` --- include/bout/physicsmodel.hxx | 27 ++++----- src/bout++.cxx | 106 ++++++++++++++++------------------ 2 files changed, 62 insertions(+), 71 deletions(-) diff --git a/include/bout/physicsmodel.hxx b/include/bout/physicsmodel.hxx index baa284c862..d952c45efb 100644 --- a/include/bout/physicsmodel.hxx +++ b/include/bout/physicsmodel.hxx @@ -418,26 +418,26 @@ private: */ #define BOUTMAIN(ModelClass) \ int main(int argc, char** argv) { \ - int init_err = BoutInitialise(argc, argv); \ - if (init_err < 0) { \ - return 0; \ - } \ - if (init_err > 0) { \ - return init_err; \ - } \ try { \ + int init_err = BoutInitialise(argc, argv); \ + if (init_err < 0) { \ + return 0; \ + } \ + if (init_err > 0) { \ + return init_err; \ + } \ auto model = bout::utils::make_unique(); \ auto solver = Solver::create(); \ solver->setModel(model.get()); \ auto bout_monitor = bout::utils::make_unique(); \ solver->addMonitor(bout_monitor.get(), Solver::BACK); \ solver->solve(); \ + BoutFinalise(); \ + return 0; \ } catch (const BoutException& e) { \ output.write("Error encountered: {}\n", e.what()); \ MPI_Abort(BoutComm::get(), 1); \ } \ - BoutFinalise(); \ - return 0; \ } /// Macro to replace solver->add, passing variable name @@ -480,8 +480,7 @@ private: /// Add fields to the solver. /// This should accept up to ten arguments -#define SOLVE_FOR(...) \ - { MACRO_FOR_EACH(SOLVE_FOR1, __VA_ARGS__) } +#define SOLVE_FOR(...) {MACRO_FOR_EACH(SOLVE_FOR1, __VA_ARGS__)} /// Write this variable once to the grid file #define SAVE_ONCE1(var) dump.addOnce(var, #var); @@ -521,8 +520,7 @@ private: dump.addOnce(var6, #var6); \ } -#define SAVE_ONCE(...) \ - { MACRO_FOR_EACH(SAVE_ONCE1, __VA_ARGS__) } +#define SAVE_ONCE(...) {MACRO_FOR_EACH(SAVE_ONCE1, __VA_ARGS__)} /// Write this variable every timestep #define SAVE_REPEAT1(var) dump.addRepeat(var, #var); @@ -562,7 +560,6 @@ private: dump.addRepeat(var6, #var6); \ } -#define SAVE_REPEAT(...) \ - { MACRO_FOR_EACH(SAVE_REPEAT1, __VA_ARGS__) } +#define SAVE_REPEAT(...) {MACRO_FOR_EACH(SAVE_REPEAT1, __VA_ARGS__)} #endif // BOUT_PHYSICS_MODEL_H diff --git a/src/bout++.cxx b/src/bout++.cxx index 9c859aaaa7..ba49a208be 100644 --- a/src/bout++.cxx +++ b/src/bout++.cxx @@ -141,74 +141,68 @@ int BoutInitialise(int& argc, char**& argv) { return 1; } - try { - checkDataDirectoryIsAccessible(args.data_dir); + checkDataDirectoryIsAccessible(args.data_dir); - // Set the command-line arguments - SlepcLib::setArgs(argc, argv); // SLEPc initialisation - PetscLib::setArgs(argc, argv); // PETSc initialisation - Solver::setArgs(argc, argv); // Solver initialisation - BoutComm::setArgs(argc, argv); // MPI initialisation + // Set the command-line arguments + SlepcLib::setArgs(argc, argv); // SLEPc initialisation + PetscLib::setArgs(argc, argv); // PETSc initialisation + Solver::setArgs(argc, argv); // Solver initialisation + BoutComm::setArgs(argc, argv); // MPI initialisation - const int MYPE = BoutComm::rank(); + const int MYPE = BoutComm::rank(); - setupBoutLogColor(args.color_output, MYPE); + setupBoutLogColor(args.color_output, MYPE); - setupOutput(args.data_dir, args.log_file, args.verbosity, MYPE); + setupOutput(args.data_dir, args.log_file, args.verbosity, MYPE); - savePIDtoFile(args.data_dir, MYPE); + savePIDtoFile(args.data_dir, MYPE); #if BOUT_HAS_ADIOS2 - bout::ADIOSInit(BoutComm::get()); + bout::ADIOSInit(BoutComm::get()); #endif - // Print the different parts of the startup info - printStartupHeader(MYPE, BoutComm::size()); - printCompileTimeOptions(); - printCommandLineArguments(args.original_argv); - - // Load settings file - OptionsReader* reader = OptionsReader::getInstance(); - // Ideally we'd use the long options for `datadir` and - // `optionfile` here, but we'd need to call parseCommandLine - // _first_ in order to do that and set the source, etc., but we - // need to call that _second_ in order to override the input file - reader->read(Options::getRoot(), "{}", (args.data_dir / args.opt_file).string()); - - // Get options override from command-line - reader->parseCommandLine(Options::getRoot(), args.argv); - - // Get the variables back out so they count as having been used - // when checking for unused options. They normally _do_ get used, - // but it's possible that only happens in BoutFinalise, which is - // too late for that check. - const auto datadir = Options::root()["datadir"].withDefault(DEFAULT_DIR); - [[maybe_unused]] const auto optionfile = - Options::root()["optionfile"].withDefault(args.opt_file); - const auto settingsfile = - Options::root()["settingsfile"].withDefault(args.set_file); - - setRunStartInfo(Options::root()); - - if (MYPE == 0) { - writeSettingsFile(Options::root(), datadir, settingsfile); - } - - bout::globals::mpi = new MpiWrapper(); + // Print the different parts of the startup info + printStartupHeader(MYPE, BoutComm::size()); + printCompileTimeOptions(); + printCommandLineArguments(args.original_argv); + + // Load settings file + OptionsReader* reader = OptionsReader::getInstance(); + // Ideally we'd use the long options for `datadir` and + // `optionfile` here, but we'd need to call parseCommandLine + // _first_ in order to do that and set the source, etc., but we + // need to call that _second_ in order to override the input file + reader->read(Options::getRoot(), "{}", (args.data_dir / args.opt_file).string()); + + // Get options override from command-line + reader->parseCommandLine(Options::getRoot(), args.argv); + + // Get the variables back out so they count as having been used + // when checking for unused options. They normally _do_ get used, + // but it's possible that only happens in BoutFinalise, which is + // too late for that check. + const auto datadir = Options::root()["datadir"].withDefault(DEFAULT_DIR); + [[maybe_unused]] const auto optionfile = + Options::root()["optionfile"].withDefault(args.opt_file); + const auto settingsfile = + Options::root()["settingsfile"].withDefault(args.set_file); + + setRunStartInfo(Options::root()); + + if (MYPE == 0) { + writeSettingsFile(Options::root(), datadir, settingsfile); + } - // Create the mesh - bout::globals::mesh = Mesh::create(); - // Load from sources. Required for Field initialisation - bout::globals::mesh->load(); + bout::globals::mpi = new MpiWrapper(); - // time_report options are used in BoutFinalise, i.e. after we - // check for unused options - Options::root()["time_report"].setConditionallyUsed(); + // Create the mesh + bout::globals::mesh = Mesh::create(); + // Load from sources. Required for Field initialisation + bout::globals::mesh->load(); - } catch (const BoutException& e) { - output_error.write(_("Error encountered during initialisation: {:s}\n"), e.what()); - throw; - } + // time_report options are used in BoutFinalise, i.e. after we + // check for unused options + Options::root()["time_report"].setConditionallyUsed(); return 0; } From 6d89b6fd6543482d8b5bda02c1d276682eb2423e Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 16:38:11 +0000 Subject: [PATCH 13/34] Don't print `MsgStack` dump if it's empty --- include/bout/msg_stack.hxx | 3 +++ src/sys/boutexception.cxx | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/bout/msg_stack.hxx b/include/bout/msg_stack.hxx index 765a3120cf..9e218e9efb 100644 --- a/include/bout/msg_stack.hxx +++ b/include/bout/msg_stack.hxx @@ -89,6 +89,9 @@ public: std::string getDump() { return ""; } #endif + /// Current stack size + std::size_t size() const { return position; } + private: std::vector stack; ///< Message stack; std::vector::size_type position{0}; ///< Position in stack diff --git a/src/sys/boutexception.cxx b/src/sys/boutexception.cxx index 8509dc40ba..931720d537 100644 --- a/src/sys/boutexception.cxx +++ b/src/sys/boutexception.cxx @@ -15,10 +15,6 @@ #include -namespace { -const std::string header{"====== Exception thrown ======\n"}; -} - bool BoutException::show_backtrace = true; void BoutParallelThrowRhsFail(int status, const char* message) { @@ -71,8 +67,13 @@ std::string BoutException::getBacktrace() const { and (frame.symbol != "_start")); }); - const std::string backtrace_message = formatter.format(generate_trace()); + std::string backtrace_message = + fmt::format("{}\n\n====== Exception thrown ======\n{}", + formatter.format(generate_trace()), message); - return fmt::format("{}\n{}\n{}{}\n", backtrace_message, msg_stack.getDump(), header, - message); + if (msg_stack.size() > 0) { + return fmt::format("{}\n\nAdditional information:\n{}", backtrace_message, + msg_stack.getDump()); + } + return backtrace_message; } From 8896f6eb05674772d7fe00e08d35471eae8319d1 Mon Sep 17 00:00:00 2001 From: ZedThree <1486942+ZedThree@users.noreply.github.com> Date: Mon, 5 Jan 2026 16:43:08 +0000 Subject: [PATCH 14/34] Apply clang-format changes --- include/bout/bout_enum_class.hxx | 5 +++-- include/bout/invertable_operator.hxx | 4 ++-- include/bout/physicsmodel.hxx | 9 ++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/bout/bout_enum_class.hxx b/include/bout/bout_enum_class.hxx index fa4abc8090..6f632747ed 100644 --- a/include/bout/bout_enum_class.hxx +++ b/include/bout/bout_enum_class.hxx @@ -85,11 +85,12 @@ BOUT_ENUM_CLASS_MAP_ARGS(BOUT_STR_ENUM_CLASS, enumname, __VA_ARGS__)}; \ auto found = fromString_map.find(s); \ if (found == fromString_map.end()) { \ - std::string valid_values {}; \ + std::string valid_values{}; \ for (auto const& entry : fromString_map) { \ valid_values += std::string(" ") + entry.first; \ } \ - throw BoutException("Did not find enum {:s}. Valid values: {:s}", s, valid_values); \ + throw BoutException("Did not find enum {:s}. Valid values: {:s}", s, \ + valid_values); \ } \ return found->second; \ } \ diff --git a/include/bout/invertable_operator.hxx b/include/bout/invertable_operator.hxx index 6dcd92897a..d61c258654 100644 --- a/include/bout/invertable_operator.hxx +++ b/include/bout/invertable_operator.hxx @@ -135,9 +135,9 @@ public: : operatorFunction(func), preconditionerFunction(func), opt(optIn == nullptr ? Options::getRoot()->getSection("invertableOperator") : optIn), - localmesh(localmeshIn == nullptr ? bout::globals::mesh : localmeshIn), lib(opt) { + localmesh(localmeshIn == nullptr ? bout::globals::mesh : localmeshIn), lib(opt){ - }; + }; /// Destructor just has to cleanup the PETSc owned objects. ~InvertableOperator() { diff --git a/include/bout/physicsmodel.hxx b/include/bout/physicsmodel.hxx index d952c45efb..81f17a39f0 100644 --- a/include/bout/physicsmodel.hxx +++ b/include/bout/physicsmodel.hxx @@ -480,7 +480,8 @@ private: /// Add fields to the solver. /// This should accept up to ten arguments -#define SOLVE_FOR(...) {MACRO_FOR_EACH(SOLVE_FOR1, __VA_ARGS__)} +#define SOLVE_FOR(...) \ + { MACRO_FOR_EACH(SOLVE_FOR1, __VA_ARGS__) } /// Write this variable once to the grid file #define SAVE_ONCE1(var) dump.addOnce(var, #var); @@ -520,7 +521,8 @@ private: dump.addOnce(var6, #var6); \ } -#define SAVE_ONCE(...) {MACRO_FOR_EACH(SAVE_ONCE1, __VA_ARGS__)} +#define SAVE_ONCE(...) \ + { MACRO_FOR_EACH(SAVE_ONCE1, __VA_ARGS__) } /// Write this variable every timestep #define SAVE_REPEAT1(var) dump.addRepeat(var, #var); @@ -560,6 +562,7 @@ private: dump.addRepeat(var6, #var6); \ } -#define SAVE_REPEAT(...) {MACRO_FOR_EACH(SAVE_REPEAT1, __VA_ARGS__)} +#define SAVE_REPEAT(...) \ + { MACRO_FOR_EACH(SAVE_REPEAT1, __VA_ARGS__) } #endif // BOUT_PHYSICS_MODEL_H From e497fcd3a0f9811538cd374369b97bb9631f9abf Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 16:59:29 +0000 Subject: [PATCH 15/34] docs: Use build directory for building library Required because cpptrace prevents in-source builds Also switch to using `subprocess.run` so we can better see errors --- manual/sphinx/conf.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/manual/sphinx/conf.py b/manual/sphinx/conf.py index 3aa6e94dc3..6b997ec111 100755 --- a/manual/sphinx/conf.py +++ b/manual/sphinx/conf.py @@ -82,22 +82,21 @@ def __getattr__(cls, name): pwd = "/".join(os.getcwd().split("/")[:-2]) os.system("git submodule update --init --recursive ../../externalpackages/fmt") cmake = ( - "cmake . -DBOUT_USE_FFTW=ON" - + " -DBOUT_USE_LAPACK=OFF" - + " -DBOUT_ENABLE_PYTHON=ON" - + " -DBOUT_UPDATE_GIT_SUBMODULE=OFF" - + " -DBOUT_TESTS=OFF" - + " -DBOUT_ALLOW_INSOURCE_BUILD=ON" - + f" -DPython3_ROOT_DIR={pydir}" - + f" -Dmpark_variant_DIR={pwd}/externalpackages/mpark.variant/" - + f" -Dfmt_DIR={pwd}/externalpackages/fmt/" + "cmake . " + " -B build" + " -DBOUT_USE_FFTW=ON" + " -DBOUT_USE_LAPACK=OFF" + " -DBOUT_ENABLE_PYTHON=ON" + " -DBOUT_UPDATE_GIT_SUBMODULE=OFF" + " -DBOUT_TESTS=OFF" + " -DBOUT_ALLOW_INSOURCE_BUILD=ON" + f" -DPython3_ROOT_DIR={pydir}" + f" -Dmpark_variant_DIR={pwd}/externalpackages/mpark.variant/" + f" -Dfmt_DIR={pwd}/externalpackages/fmt/" ) - # os.system("mkdir ../../build") - os.system("echo " + cmake) - x = os.system("cd ../.. ;" + cmake) - assert x == 0 - x = os.system("cd ../.. ; make -j 2 -f Makefile") - assert x == 0 + subprocess.run(f"echo {cmake}", shell=True) + subprocess.run(f"cd ../../; {cmake}", shell=True, check=True) + subprocess.run("cd ../.. ; cmake --build build -j 2", shell=True, check=True) # readthedocs currently runs out of memory if we actually dare to try to do this From 6ccdca8fd2877dee1bbc04bd09b682f92fee9739 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 5 Jan 2026 17:23:41 +0000 Subject: [PATCH 16/34] Partial revert of d0cd5f0aee Seems to cause MPI problems? --- include/bout/physicsmodel.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/bout/physicsmodel.hxx b/include/bout/physicsmodel.hxx index 81f17a39f0..e6d34daef9 100644 --- a/include/bout/physicsmodel.hxx +++ b/include/bout/physicsmodel.hxx @@ -432,12 +432,12 @@ private: auto bout_monitor = bout::utils::make_unique(); \ solver->addMonitor(bout_monitor.get(), Solver::BACK); \ solver->solve(); \ - BoutFinalise(); \ - return 0; \ } catch (const BoutException& e) { \ output.write("Error encountered: {}\n", e.what()); \ MPI_Abort(BoutComm::get(), 1); \ } \ + BoutFinalise(); \ + return 0; \ } /// Macro to replace solver->add, passing variable name From d8b360fee146fd8837330943a3fa20523b8f4974 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Tue, 6 Jan 2026 14:19:22 +0000 Subject: [PATCH 17/34] Remove some more unused headers --- include/bout/deriv_store.hxx | 1 + include/bout/msg_stack.hxx | 6 ++---- src/field/field2d.cxx | 2 -- src/solver/impls/adams_bashforth/adams_bashforth.cxx | 3 --- src/solver/impls/euler/euler.cxx | 1 - src/sys/derivs.cxx | 1 - 6 files changed, 3 insertions(+), 11 deletions(-) diff --git a/include/bout/deriv_store.hxx b/include/bout/deriv_store.hxx index 0e03d6a32e..b2b7928c2e 100644 --- a/include/bout/deriv_store.hxx +++ b/include/bout/deriv_store.hxx @@ -29,6 +29,7 @@ #ifndef __DERIV_STORE_HXX__ #define __DERIV_STORE_HXX__ +#include #include #include #include diff --git a/include/bout/msg_stack.hxx b/include/bout/msg_stack.hxx index 9e218e9efb..1abb26d2c7 100644 --- a/include/bout/msg_stack.hxx +++ b/include/bout/msg_stack.hxx @@ -31,11 +31,9 @@ class MsgStack; #include "bout/build_defines.hxx" -#include "bout/unused.hxx" - #include "fmt/core.h" -#include +#include #include #include #include @@ -82,7 +80,7 @@ public: } void pop() {} - void pop(int UNUSED(id)) {} + void pop(int [[maybe_unused]] id) {} void clear() {} void dump() {} diff --git a/src/field/field2d.cxx b/src/field/field2d.cxx index 01f2d8c4a6..a046078585 100644 --- a/src/field/field2d.cxx +++ b/src/field/field2d.cxx @@ -36,8 +36,6 @@ #include // for mesh #include #include -#include -#include #include diff --git a/src/solver/impls/adams_bashforth/adams_bashforth.cxx b/src/solver/impls/adams_bashforth/adams_bashforth.cxx index 72748fd52e..51fff4fe6a 100644 --- a/src/solver/impls/adams_bashforth/adams_bashforth.cxx +++ b/src/solver/impls/adams_bashforth/adams_bashforth.cxx @@ -5,9 +5,6 @@ #include #include #include -#include - -#include namespace { BoutReal lagrange_at_position_denominator(const std::deque& grid, diff --git a/src/solver/impls/euler/euler.cxx b/src/solver/impls/euler/euler.cxx index 2a9e5813f2..a3911e78d6 100644 --- a/src/solver/impls/euler/euler.cxx +++ b/src/solver/impls/euler/euler.cxx @@ -5,7 +5,6 @@ #include #include #include -#include EulerSolver::EulerSolver(Options* options) : Solver(options), mxstep((*options)["mxstep"] diff --git a/src/sys/derivs.cxx b/src/sys/derivs.cxx index 13be388e97..aab75b8f19 100644 --- a/src/sys/derivs.cxx +++ b/src/sys/derivs.cxx @@ -45,7 +45,6 @@ #include #include #include -#include #include #include From 5306125a4a9bb834888e1949ddf8f1cbfd7d6bdf Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Tue, 6 Jan 2026 14:19:34 +0000 Subject: [PATCH 18/34] tests: Add functions to anon namespace --- tests/integrated/test-backtrace/boutexcept.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integrated/test-backtrace/boutexcept.cxx b/tests/integrated/test-backtrace/boutexcept.cxx index 70bf480862..6017ecd8f9 100644 --- a/tests/integrated/test-backtrace/boutexcept.cxx +++ b/tests/integrated/test-backtrace/boutexcept.cxx @@ -1,8 +1,10 @@ #include "bout/boutexception.hxx" +namespace { void troublemaker() { throw BoutException("test"); } void f() { troublemaker(); } void e() { f(); } +} int main() { e(); From 68fab1b2e338c0631e15372b2f1255642d693807 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Tue, 6 Jan 2026 14:19:45 +0000 Subject: [PATCH 19/34] Don't use `char[]` for constant --- src/bout++.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bout++.cxx b/src/bout++.cxx index ba49a208be..d6888874c6 100644 --- a/src/bout++.cxx +++ b/src/bout++.cxx @@ -27,7 +27,7 @@ #include "bout/build_config.hxx" -const char DEFAULT_DIR[] = "data"; +static constexpr auto DEFAULT_DIR = "data"; #define GLOBALORIGIN From 563ab24f4a30ba18b85f9a25d28ab4f3a78f637d Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Tue, 6 Jan 2026 14:22:59 +0000 Subject: [PATCH 20/34] Fix use of reserved identifier --- include/bout/scorepwrapper.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/bout/scorepwrapper.hxx b/include/bout/scorepwrapper.hxx index 40c2232040..8b37b2ff61 100644 --- a/include/bout/scorepwrapper.hxx +++ b/include/bout/scorepwrapper.hxx @@ -20,9 +20,9 @@ /// we need to say if we support this or not by defining BOUT_HAS_PRETTY_FUNCTION (to be /// implemented in configure) #if BOUT_HAS_PRETTY_FUNCTION -#define __thefunc__ __PRETTY_FUNCTION__ +#define _thefunc_ __PRETTY_FUNCTION__ #else -#define __thefunc__ __func__ +#define _thefunc_ __func__ #endif /// Instrument a function with scorep @@ -31,7 +31,7 @@ /// If we don't have scorep support then just define a null function #if BOUT_HAS_SCOREP #define SCOREP_BASE_CALL(...) \ - SCOREP_USER_REGION(__thefunc__, SCOREP_USER_REGION_TYPE_FUNCTION) + SCOREP_USER_REGION(_thefunc_, SCOREP_USER_REGION_TYPE_FUNCTION) #else #define SCOREP_BASE_CALL(...) #endif From 1a9210cbc6a846caaef63bc2cb562a65bff349e5 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Tue, 6 Jan 2026 14:45:16 +0000 Subject: [PATCH 21/34] docs: Update example backtrace --- manual/sphinx/developer_docs/debugging.rst | 97 +++++++++++++--------- src/sys/boutexception.cxx | 2 +- src/sys/msg_stack.cxx | 2 +- 3 files changed, 58 insertions(+), 43 deletions(-) diff --git a/manual/sphinx/developer_docs/debugging.rst b/manual/sphinx/developer_docs/debugging.rst index fc8d80d9fc..4e8bd0feab 100644 --- a/manual/sphinx/developer_docs/debugging.rst +++ b/manual/sphinx/developer_docs/debugging.rst @@ -69,14 +69,15 @@ help find where an error occurred. For example, given this snippet:: we would see something like the following output: .. code:: text - - ====== Back trace ====== + + ====== Exception thrown ====== + Something went wrong + + === Additional information === -> 4. Inner-most scope on line 58 of '/path/to/model.cxx' -> 2. Middle scope on line 53 of '/path/to/model.cxx' -> 1. Outer-most scope on line 51 of '/path/to/model.cxx' - ====== Exception thrown ====== - Something went wrong The third ``TRACE`` message doesn't appear in the output because we've left its scope and it's no longer relevant. @@ -97,44 +98,58 @@ the ``fmt`` syntax also used by the loggers:: Backtrace ========= -Lastly, BOUT++ can also automatically print a backtrace in the event -of a crash. This is a compile-time option in the BOUT++ library -(``-DBOUT_ENABLE_BACKTRACE=ON``, the default, requires the -``addr2line`` program to be installed), and debug symbols to be turned -on (``-DCMAKE_BUILD_TYPE=Debug`` or ``=RelWithDebInfo``) in BOUT++ -_and_ the physics model. If debug symbols are only present in part, the -backtrace will be missing names for the other part. - -The output looks something like this: +Lastly, BOUT++ can also automatically print a backtrace in the event of a +crash. This is very useful to include if you ever need to report a bug to the +developers! The output looks something like this: .. code:: text ... - Error encountered - ====== Exception path ====== - [bt] #10 ./backtrace() [0x40a27e] - _start at /home/abuild/rpmbuild/BUILD/glibc-2.33/csu/../sysdeps/x86_64/start.S:122 - [bt] #9 /lib64/libc.so.6(__libc_start_main+0xd5) [0x7fecbfa28b25] - __libc_start_main at /usr/src/debug/glibc-2.33-4.1.x86_64/csu/../csu/libc-start.c:332 - [bt] #8 ./backtrace() [0x40a467] - main at /path/to/BOUT-dev/build/../examples/backtrace/backtrace.cxx:32 (discriminator 9) - [bt] #7 /path/to/BOUT-dev/build/libbout++.so(_ZN6Solver8setModelEP12PhysicsModel+0xb5) [0x7fecc0ca2e93] - Solver::setModel(PhysicsModel*) at /path/to/BOUT-dev/build/../src/solver/solver.cxx:94 - [bt] #6 /path/to/BOUT-dev/build/libbout++.so(_ZN12PhysicsModel10initialiseEP6Solver+0xc0) [0x7fecc0cad594] - PhysicsModel::initialise(Solver*) at /path/to/BOUT-dev/build/../include/bout/physicsmodel.hxx:93 (discriminator 5) - [bt] #5 ./backtrace() [0x40a986] - Backtrace::init(bool) at /path/to/BOUT-dev/build/../examples/backtrace/backtrace.cxx:27 - [bt] #4 ./backtrace() [0x40a3cf] - f3() at /path/to/BOUT-dev/build/../examples/backtrace/backtrace.cxx:19 - [bt] #3 ./backtrace() [0x40a3be] - f2(int) at /path/to/BOUT-dev/build/../examples/backtrace/backtrace.cxx:15 - [bt] #2 ./backtrace() [0x40a386] - f1() at /path/to/BOUT-dev/build/../examples/backtrace/backtrace.cxx:13 (discriminator 2) - [bt] #1 ./backtrace(_ZN13BoutExceptionC1IA19_cJEEERKT_DpRKT0_+0xba) [0x40ae16] - BoutException::BoutException(char const (&) [19]) at /path/to/BOUT-dev/build/../include/bout/../boutexception.hxx:28 (discriminator 2) - - -This output tends to be much harder to read than the message stack -from ``TRACE`` macros, but the advantage is that it doesn't require -any modifications to the code to use, and can give you more precise -location information. + Error encountered: Stack trace (most recent call first): + #0 (filtered) + #1 (filtered) + #2 (filtered) + #3 in BoutMesh::createCommunicators() + at BOUT-dev/src/mesh/impls/bout/boutmesh.cxx:709:64 + 707: } + 708: // Unconditional exception for demo purposes + > 709: throw BoutException("Single null outer SOL not correct\n"); + ^ + 710: MPI_Group_free(&group); + 711: } + #4 in BoutMesh::load() + at BOUT-dev/src/mesh/impls/bout/boutmesh.cxx:575:22 + 573: /// Communicator + 574: + > 575: createCommunicators(); + ^ + 576: output_debug << "Got communicators" << endl; + #5 in BoutInitialise(int&, char**&) + at BOUT-dev/src/bout++.cxx:201:28 + 199: bout::globals::mesh = Mesh::create(); + 200: // Load from sources. Required for Field initialisation + > 201: bout::globals::mesh->load(); + ^ + 202: + 203: // time_report options are used in BoutFinalise, i.e. after we + #6 in main + at BOUT-dev/examples/elm-pb/elm_pb.cxx:2161:1 + 2159: }; + 2160: + > 2161: BOUTMAIN(ELMpb); + ^ + #7 (filtered) + #8 (filtered) + #9 (filtered) + + ====== Exception thrown ====== + Single null outer SOL not correct + + +Debug symbols are required to get the filename/line number and code snippets. If +they are missing in either BOUT++ or the physics model, only the function name +and signature will be included for that part. + +Including debug symbols is a configure time ``CMake`` option, set either: +``-DCMAKE_BUILD_TYPE=Debug`` or ``-DCMAKE_BUILD_TYPE=RelWithDebInfo`` (the +default). diff --git a/src/sys/boutexception.cxx b/src/sys/boutexception.cxx index 931720d537..02b6ef3391 100644 --- a/src/sys/boutexception.cxx +++ b/src/sys/boutexception.cxx @@ -72,7 +72,7 @@ std::string BoutException::getBacktrace() const { formatter.format(generate_trace()), message); if (msg_stack.size() > 0) { - return fmt::format("{}\n\nAdditional information:\n{}", backtrace_message, + return fmt::format("{}\n\n{}", backtrace_message, msg_stack.getDump()); } return backtrace_message; diff --git a/src/sys/msg_stack.cxx b/src/sys/msg_stack.cxx index 81eb6c4b0f..3dbd7c2797 100644 --- a/src/sys/msg_stack.cxx +++ b/src/sys/msg_stack.cxx @@ -91,7 +91,7 @@ void MsgStack::dump() { } std::string MsgStack::getDump() { - std::string res = "====== Back trace ======\n"; + std::string res = "=== Additional information ===\n"; for (int i = position - 1; i >= 0; i--) { if (stack[i] != "") { res += " -> "; From 4ac87c13a12b4fda73c9b5bcf6a5606138656fe0 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Thu, 8 Jan 2026 15:17:57 +0000 Subject: [PATCH 22/34] docs: Expand on using `cpptrace` and the backtrace --- manual/sphinx/developer_docs/debugging.rst | 125 +++++++++++---------- manual/sphinx/user_docs/installing.rst | 13 ++- 2 files changed, 74 insertions(+), 64 deletions(-) diff --git a/manual/sphinx/developer_docs/debugging.rst b/manual/sphinx/developer_docs/debugging.rst index 4e8bd0feab..f16d0b6a3b 100644 --- a/manual/sphinx/developer_docs/debugging.rst +++ b/manual/sphinx/developer_docs/debugging.rst @@ -34,10 +34,74 @@ To enable the ``output_debug`` messages, configure BOUT++ with a configure BOUT++ with ``-DENABLE_OUTPUT_DEBUG``. When running BOUT++ add a ``-v -v`` flag to see ``output_debug`` messages. +Backtrace +========= + +BOUT++ can also automatically print a backtrace in the event of a crash. This is +very useful to include if you ever need to report a bug to the developers! The +output looks something like this: + +.. code:: text + + ... + Error encountered: Stack trace (most recent call first): + #0 (filtered) + #1 (filtered) + #2 (filtered) + #3 in BoutMesh::createCommunicators() + at BOUT-dev/src/mesh/impls/bout/boutmesh.cxx:709:64 + 707: } + 708: // Unconditional exception for demo purposes + > 709: throw BoutException("Single null outer SOL not correct\n"); + ^ + 710: MPI_Group_free(&group); + 711: } + #4 in BoutMesh::load() + at BOUT-dev/src/mesh/impls/bout/boutmesh.cxx:575:22 + 573: /// Communicator + 574: + > 575: createCommunicators(); + ^ + 576: output_debug << "Got communicators" << endl; + #5 in BoutInitialise(int&, char**&) + at BOUT-dev/src/bout++.cxx:201:28 + 199: bout::globals::mesh = Mesh::create(); + 200: // Load from sources. Required for Field initialisation + > 201: bout::globals::mesh->load(); + ^ + 202: + 203: // time_report options are used in BoutFinalise, i.e. after we + #6 in main + at BOUT-dev/examples/elm-pb/elm_pb.cxx:2161:1 + 2159: }; + 2160: + > 2161: BOUTMAIN(ELMpb); + ^ + #7 (filtered) + #8 (filtered) + #9 (filtered) + + ====== Exception thrown ====== + Single null outer SOL not correct + + +Debug symbols are required to get the filename/line number and code snippets. If +they are missing in either BOUT++ or the physics model, only the function name +and signature will be included for that part. + +Including debug symbols is a configure time ``CMake`` option, set either: +``-DCMAKE_BUILD_TYPE=Debug`` or ``-DCMAKE_BUILD_TYPE=RelWithDebInfo`` (the +default). + +The formatting of this backtrace is controlled in +`BoutException::getBacktrace()` using the `cpptrace +`_ library. + + Message Stack ============= -The second utility BOUT++ has to help debugging is the message stack using the +Another utility BOUT++ has to help debugging is the message stack using the `TRACE` macro. This is very useful for when a bug only occurs after a long time of running, and/or only occasionally. The ``TRACE`` macro can simply be dropped in anywhere in the code:: @@ -94,62 +158,3 @@ If you need to capture runtime information in the message, you can use the ``fmt`` syntax also used by the loggers:: TRACE("Value of i={}, some arbitrary {}", i, "string"); - -Backtrace -========= - -Lastly, BOUT++ can also automatically print a backtrace in the event of a -crash. This is very useful to include if you ever need to report a bug to the -developers! The output looks something like this: - -.. code:: text - - ... - Error encountered: Stack trace (most recent call first): - #0 (filtered) - #1 (filtered) - #2 (filtered) - #3 in BoutMesh::createCommunicators() - at BOUT-dev/src/mesh/impls/bout/boutmesh.cxx:709:64 - 707: } - 708: // Unconditional exception for demo purposes - > 709: throw BoutException("Single null outer SOL not correct\n"); - ^ - 710: MPI_Group_free(&group); - 711: } - #4 in BoutMesh::load() - at BOUT-dev/src/mesh/impls/bout/boutmesh.cxx:575:22 - 573: /// Communicator - 574: - > 575: createCommunicators(); - ^ - 576: output_debug << "Got communicators" << endl; - #5 in BoutInitialise(int&, char**&) - at BOUT-dev/src/bout++.cxx:201:28 - 199: bout::globals::mesh = Mesh::create(); - 200: // Load from sources. Required for Field initialisation - > 201: bout::globals::mesh->load(); - ^ - 202: - 203: // time_report options are used in BoutFinalise, i.e. after we - #6 in main - at BOUT-dev/examples/elm-pb/elm_pb.cxx:2161:1 - 2159: }; - 2160: - > 2161: BOUTMAIN(ELMpb); - ^ - #7 (filtered) - #8 (filtered) - #9 (filtered) - - ====== Exception thrown ====== - Single null outer SOL not correct - - -Debug symbols are required to get the filename/line number and code snippets. If -they are missing in either BOUT++ or the physics model, only the function name -and signature will be included for that part. - -Including debug symbols is a configure time ``CMake`` option, set either: -``-DCMAKE_BUILD_TYPE=Debug`` or ``-DCMAKE_BUILD_TYPE=RelWithDebInfo`` (the -default). diff --git a/manual/sphinx/user_docs/installing.rst b/manual/sphinx/user_docs/installing.rst index 10f5d9b9f1..2c4b8e847d 100644 --- a/manual/sphinx/user_docs/installing.rst +++ b/manual/sphinx/user_docs/installing.rst @@ -332,10 +332,13 @@ The default build configuration options try to be sensible for new users and developers, but there are a few you probably want to set manually for production runs or for debugging: -* ``CMAKE_BUILD_TYPE``: The default is ``RelWithDebInfo``, which - builds an optimised executable with debug symbols included. Change - this to ``Release`` to remove the debug symbols, or ``Debug`` for an - unoptimised build, but better debug experience +* ``CMAKE_BUILD_TYPE``: The default is ``RelWithDebInfo``, which builds an + optimised executable with debug symbols included. This is generally the most + useful, except for developers, who may wish to use ``Debug`` for an + unoptimised build, but better debug experience. There are a couple of other + choices (``Release`` and ``MinSizeRel``) which also produce optimised + executables, but without debug symbols, which is only really useful for + producing smaller binaries. * ``CHECK``: This sets the level of internal runtime checking done in the BOUT++ library, and ranges from 0 to 4 (inclusive). By default, @@ -377,6 +380,8 @@ For ADIOS2, use ``-DBOUT_DOWNLOAD_ADIOS2=ON``. This will download and configure `ADIOS2 `_, enabling BOUT++ to read and write this high-performance parallel file format. +For cpptrace, use ``-DBOUT_DOWNLOAD_CPPTRACE=on`` (the default). + Bundled Dependencies ~~~~~~~~~~~~~~~~~~~~ From 73e585768078fb32364d8801c30c36e46f6807f8 Mon Sep 17 00:00:00 2001 From: ZedThree <1486942+ZedThree@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:18:45 +0000 Subject: [PATCH 23/34] Apply clang-format changes --- src/sys/boutexception.cxx | 3 +-- tests/integrated/test-backtrace/boutexcept.cxx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sys/boutexception.cxx b/src/sys/boutexception.cxx index 02b6ef3391..b5ea01d231 100644 --- a/src/sys/boutexception.cxx +++ b/src/sys/boutexception.cxx @@ -72,8 +72,7 @@ std::string BoutException::getBacktrace() const { formatter.format(generate_trace()), message); if (msg_stack.size() > 0) { - return fmt::format("{}\n\n{}", backtrace_message, - msg_stack.getDump()); + return fmt::format("{}\n\n{}", backtrace_message, msg_stack.getDump()); } return backtrace_message; } diff --git a/tests/integrated/test-backtrace/boutexcept.cxx b/tests/integrated/test-backtrace/boutexcept.cxx index 6017ecd8f9..6ebe2d05c4 100644 --- a/tests/integrated/test-backtrace/boutexcept.cxx +++ b/tests/integrated/test-backtrace/boutexcept.cxx @@ -4,7 +4,7 @@ namespace { void troublemaker() { throw BoutException("test"); } void f() { troublemaker(); } void e() { f(); } -} +} // namespace int main() { e(); From 8edb351b1f75382ae014f770676c239ee92e74be Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Thu, 8 Jan 2026 16:01:24 +0000 Subject: [PATCH 24/34] tests: Fix exception test inlining functions --- tests/integrated/test-backtrace/boutexcept.cxx | 6 ++++-- tests/integrated/test-backtrace/runtest | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/integrated/test-backtrace/boutexcept.cxx b/tests/integrated/test-backtrace/boutexcept.cxx index 6ebe2d05c4..3019c690a9 100644 --- a/tests/integrated/test-backtrace/boutexcept.cxx +++ b/tests/integrated/test-backtrace/boutexcept.cxx @@ -1,10 +1,12 @@ #include "bout/boutexception.hxx" -namespace { +// Can't use anonymous namespace, or the compiler will inline everything, +// defeating the point of this test. +// NOLINTBEGIN(misc-use-internal-linkage) void troublemaker() { throw BoutException("test"); } void f() { troublemaker(); } void e() { f(); } -} // namespace +// NOLINTEND(misc-use-internal-linkage) int main() { e(); diff --git a/tests/integrated/test-backtrace/runtest b/tests/integrated/test-backtrace/runtest index 4010873b56..06497ec65a 100755 --- a/tests/integrated/test-backtrace/runtest +++ b/tests/integrated/test-backtrace/runtest @@ -21,13 +21,13 @@ _, output = shell("BOUT_SHOW_BACKTRACE=0 ./boutexcept", pipe=True) if "troublemaker" in output: success = False - print("Fail: detected offending function name in output when not expected") + print(f"Fail: detected offending function name in output when not expected:\n{output}") _, output = shell("./boutexcept", pipe=True) if "troublemaker" not in output: success = False - print("Fail: did not detect offending function name in output when expected") + print(f"Fail: did not detect offending function name in output when expected:\n{output}") if success: print("=> All BoutException backtrace tests passed") From 6b03b6c1c214f476cf2280ddcfe69a336b324df4 Mon Sep 17 00:00:00 2001 From: ZedThree <1486942+ZedThree@users.noreply.github.com> Date: Thu, 8 Jan 2026 16:02:30 +0000 Subject: [PATCH 25/34] Apply black changes --- tests/integrated/test-backtrace/runtest | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/integrated/test-backtrace/runtest b/tests/integrated/test-backtrace/runtest index 06497ec65a..c4020e6d99 100755 --- a/tests/integrated/test-backtrace/runtest +++ b/tests/integrated/test-backtrace/runtest @@ -21,13 +21,17 @@ _, output = shell("BOUT_SHOW_BACKTRACE=0 ./boutexcept", pipe=True) if "troublemaker" in output: success = False - print(f"Fail: detected offending function name in output when not expected:\n{output}") + print( + f"Fail: detected offending function name in output when not expected:\n{output}" + ) _, output = shell("./boutexcept", pipe=True) if "troublemaker" not in output: success = False - print(f"Fail: did not detect offending function name in output when expected:\n{output}") + print( + f"Fail: did not detect offending function name in output when expected:\n{output}" + ) if success: print("=> All BoutException backtrace tests passed") From 9855b5f21cb8e4b19d5c430033e57d0aa239bbe8 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 9 Jan 2026 13:50:02 +0000 Subject: [PATCH 26/34] Add `cpptrace` as git submodule --- .gitmodules | 3 ++ cmake/SetupBOUTThirdParty.cmake | 28 +++++++++++-------- externalpackages/cpptrace | 1 + manual/sphinx/user_docs/installing.rst | 38 ++++++++++++++++++-------- 4 files changed, 47 insertions(+), 23 deletions(-) create mode 160000 externalpackages/cpptrace diff --git a/.gitmodules b/.gitmodules index 4b33b3b615..2bdbd2a57b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "externalpackages/boutdata"] path = externalpackages/boutdata url = https://github.com/boutproject/boutdata.git +[submodule "externalpackages/cpptrace"] + path = externalpackages/cpptrace + url = https://github.com/ZedThree/cpptrace.git diff --git a/cmake/SetupBOUTThirdParty.cmake b/cmake/SetupBOUTThirdParty.cmake index 2c5b9a1cfb..52b7468012 100644 --- a/cmake/SetupBOUTThirdParty.cmake +++ b/cmake/SetupBOUTThirdParty.cmake @@ -370,18 +370,24 @@ endif() message(STATUS "UUID_SYSTEM_GENERATOR: ${BOUT_USE_UUID_SYSTEM_GENERATOR}") set(BOUT_HAS_UUID_SYSTEM_GENERATOR ${BOUT_USE_UUID_SYSTEM_GENERATOR}) -option(BOUT_DOWNLOAD_CPPTRACE "Download cpptrace for backtrace support" ON) -if (BOUT_DOWNLOAD_CPPTRACE) - include(FetchContent) +cmake_dependent_option(BOUT_USE_SYSTEM_CPPTRACE "Use external installation of cpptrace" OFF + "BOUT_UPDATE_GIT_SUBMODULE OR EXISTS ${PROJECT_SOURCE_DIR}/externalpackages/cpptrace/CMakeLists.txt" ON) + +if(BOUT_USE_SYSTEM_CPPTRACE) + message(STATUS "Using external cpptrace") + find_package(cpptrace REQUIRED) + get_target_property(CPPTRACE_INCLUDE_PATH cpptrace::cpptrace INTERFACE_INCLUDE_DIRECTORIES) +else() + message(STATUS "Using cpptrace submodule") + bout_update_submodules() + # Need a fork with some fixes for CMake set(CPPTRACE_LIBDWARF_REPO "https://github.com/ZedThree/libdwarf-lite.git" CACHE STRING "" FORCE) set(CPPTRACE_LIBDWARF_TAG "ebe10a39afd56b8247de633bfe17666ad50ab95e" CACHE STRING "" FORCE) - FetchContent_Declare( - cpptrace - GIT_REPOSITORY https://github.com/ZedThree/cpptrace.git - GIT_TAG "027f9aee2d34dbe1c98f26224e1fbe1654cb4aae" - ) - FetchContent_MakeAvailable(cpptrace) -else() - find_package(cpptrace REQUIRED) + add_subdirectory(externalpackages/cpptrace) + if(NOT TARGET cpptrace::cpptrace) + message(FATAL_ERROR "cpptrace not found! Have you disabled the git submodules (BOUT_UPDATE_GIT_SUBMODULE)?") + endif() + set(CPPTRACE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externalpackages/cpptrace/include") endif() +set(CONFIG_CFLAGS "${CONFIG_CFLAGS} -I\${CPPTRACE_INCLUDE_PATH}") target_link_libraries(bout++ PUBLIC cpptrace::cpptrace) diff --git a/externalpackages/cpptrace b/externalpackages/cpptrace new file mode 160000 index 0000000000..027f9aee2d --- /dev/null +++ b/externalpackages/cpptrace @@ -0,0 +1 @@ +Subproject commit 027f9aee2d34dbe1c98f26224e1fbe1654cb4aae diff --git a/manual/sphinx/user_docs/installing.rst b/manual/sphinx/user_docs/installing.rst index 2c4b8e847d..a493f932c4 100644 --- a/manual/sphinx/user_docs/installing.rst +++ b/manual/sphinx/user_docs/installing.rst @@ -380,21 +380,35 @@ For ADIOS2, use ``-DBOUT_DOWNLOAD_ADIOS2=ON``. This will download and configure `ADIOS2 `_, enabling BOUT++ to read and write this high-performance parallel file format. -For cpptrace, use ``-DBOUT_DOWNLOAD_CPPTRACE=on`` (the default). - Bundled Dependencies ~~~~~~~~~~~~~~~~~~~~ -BOUT++ bundles some dependencies, currently `mpark.variant -`_, `fmt `_ and -`googletest `_. If you wish to -use an existing installation of ``mpark.variant``, you can set -``-DBOUT_USE_SYSTEM_MPARK_VARIANT=ON``, and supply the installation -path using ``mpark_variant_ROOT`` via the command line or environment -variable if it is installed in a non standard loction. Similarly for -``fmt``, using ``-DBOUT_USE_SYSTEM_FMT=ON`` and ``fmt_ROOT`` -respectively. To turn off both, you can set -``-DBOUT_USE_GIT_SUBMODULE=OFF``. +BOUT++ bundles some dependencies, currently: + +- `mpark.variant `_ +- `fmt `_ +- `cpptrace `_ +- ``googletest `_ (for unit tests) + +Aside from ``googletest``, the others are required dependencies and can either +be built as part of the BOUT++ build, or provided externally. If you wish to use +existing installations of some of these, set the following flags: + ++--------------------+-----------------------------------+------------------------+ +| Name | Flag for external installation | Library path | ++====================+===================================+========================+ +| ``mpark.variant`` | ``BOUT_USE_SYSTEM_MPARK_VARIANT`` | ``mpark_variant_ROOT`` | ++--------------------+-----------------------------------+------------------------+ +| ``fmt`` | ``BOUT_USE_SYSTEM_FMT`` | ``fmt_ROOT`` | ++--------------------+-----------------------------------+------------------------+ +| ``cpptrace`` | ``BOUT_USE_SYSTEM_CPPTRACE`` | ``cpptrace_ROOT`` | ++--------------------+-----------------------------------+------------------------+ + +You can also set ``-DBOUT_USE_GIT_SUBMODULE=OFF`` to not use any of the bundled +versions. + +If the libraries are in non-standard locations, you may also need to supply the +relevant library path flags. The recommended way to use ``googletest`` is to compile it at the same time as your project, therefore there is no option to use an external From 7fa1c5f3ff790f4a641c0f54d443d924e93ae48f Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 9 Jan 2026 17:12:06 +0000 Subject: [PATCH 27/34] boutpp: Add `cpptrace` to sdist --- tools/pylib/_boutpp_build/backend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pylib/_boutpp_build/backend.py b/tools/pylib/_boutpp_build/backend.py index 31a4694d10..6455c203ad 100755 --- a/tools/pylib/_boutpp_build/backend.py +++ b/tools/pylib/_boutpp_build/backend.py @@ -176,7 +176,7 @@ def build_sdist(sdist_directory, config_settings=None): print(config_settings, sdist_directory) enable_gz = True enable_xz = False - external = {"fmt", "mpark.variant"} + external = {"fmt", "mpark.variant", "cpptrace"} if config_settings is not None: global useLocalVersion, pkgname for k, v in config_settings.items(): From 68904f93c08637dd2394f93bcfb42d62c2bc3848 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 9 Jan 2026 17:12:26 +0000 Subject: [PATCH 28/34] docs: Init all submodules --- manual/sphinx/conf.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/manual/sphinx/conf.py b/manual/sphinx/conf.py index 6b997ec111..5c6b7ef1d5 100755 --- a/manual/sphinx/conf.py +++ b/manual/sphinx/conf.py @@ -76,11 +76,7 @@ def __getattr__(cls, name): pydir = "/".join(python.split("/")[:-2]) os.system("which clang-format") os.system("which clang-format-6.0") - os.system( - "git submodule update --init --recursive ../../externalpackages/mpark.variant" - ) - pwd = "/".join(os.getcwd().split("/")[:-2]) - os.system("git submodule update --init --recursive ../../externalpackages/fmt") + subprocess.run("git submodule update --init --recursive", shell=True) cmake = ( "cmake . " " -B build" @@ -91,8 +87,6 @@ def __getattr__(cls, name): " -DBOUT_TESTS=OFF" " -DBOUT_ALLOW_INSOURCE_BUILD=ON" f" -DPython3_ROOT_DIR={pydir}" - f" -Dmpark_variant_DIR={pwd}/externalpackages/mpark.variant/" - f" -Dfmt_DIR={pwd}/externalpackages/fmt/" ) subprocess.run(f"echo {cmake}", shell=True) subprocess.run(f"cd ../../; {cmake}", shell=True, check=True) From 4a09719018050984656ed31309a3910b7ca73ca8 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Fri, 9 Jan 2026 17:31:07 +0000 Subject: [PATCH 29/34] cmake: Update cpptrace include dir for install --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7864705519..a5ca6e8717 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -818,6 +818,9 @@ endif() if (NOT BOUT_USE_SYSTEM_FMT) set(FMT_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") endif() +if (NOT BOUT_USE_SYSTEM_CPPTRACE) + set(CPPTRACE_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") +endif() set(BOUT_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") # We don't need the build include path any more string(REPLACE "-I${CMAKE_CURRENT_BINARY_DIR}/include" "" CONFIG_CFLAGS "${CONFIG_CFLAGS}") From 52299eaf8a6e76a88bbe5329aae67af9b2382634 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 19 Jan 2026 10:25:41 +0000 Subject: [PATCH 30/34] docs: Fix building `boutpp` docs on readthedocs --- manual/sphinx/conf.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/manual/sphinx/conf.py b/manual/sphinx/conf.py index 5c6b7ef1d5..6f2e12f349 100755 --- a/manual/sphinx/conf.py +++ b/manual/sphinx/conf.py @@ -78,8 +78,8 @@ def __getattr__(cls, name): os.system("which clang-format-6.0") subprocess.run("git submodule update --init --recursive", shell=True) cmake = ( - "cmake . " - " -B build" + "cmake -S ../.. " + " -B bout_build" " -DBOUT_USE_FFTW=ON" " -DBOUT_USE_LAPACK=OFF" " -DBOUT_ENABLE_PYTHON=ON" @@ -89,8 +89,12 @@ def __getattr__(cls, name): f" -DPython3_ROOT_DIR={pydir}" ) subprocess.run(f"echo {cmake}", shell=True) - subprocess.run(f"cd ../../; {cmake}", shell=True, check=True) - subprocess.run("cd ../.. ; cmake --build build -j 2", shell=True, check=True) + subprocess.run(f"{cmake}", shell=True, check=True) + subprocess.run("cmake --build bout_build", shell=True, check=True) + + # Add the build directory to sys.path so that sphinx picks up the built + # Python modules + sys.path.append("bout_build/tools/pylib") # readthedocs currently runs out of memory if we actually dare to try to do this From 60546f61ecd25c825862e08a4f18c568c56b89e4 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 19 Jan 2026 10:26:16 +0000 Subject: [PATCH 31/34] docs: Exclude CMake-built dependencies from docs --- manual/doxygen/Doxyfile | 3 ++- manual/doxygen/Doxyfile_readthedocs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/manual/doxygen/Doxyfile b/manual/doxygen/Doxyfile index 82cfa5a8a4..973c5fce58 100644 --- a/manual/doxygen/Doxyfile +++ b/manual/doxygen/Doxyfile @@ -840,7 +840,8 @@ EXCLUDE = ../../examples \ ../../manual/ \ ../../bin/ \ ../../externalpackages/googletest/ \ - ../../tests/ + ../../tests/ \ + ../../build/_deps/ # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded diff --git a/manual/doxygen/Doxyfile_readthedocs b/manual/doxygen/Doxyfile_readthedocs index 0ddca11de0..08de92fc79 100644 --- a/manual/doxygen/Doxyfile_readthedocs +++ b/manual/doxygen/Doxyfile_readthedocs @@ -790,7 +790,8 @@ EXCLUDE = ../../examples \ ../../manual/ \ ../../bin/ \ ../../externalpackages/googletest/ \ - ../../tests/ + ../../tests/ \ + ../sphinx/bout_build/_deps/ # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded From f9cb4d8a4c9b31ced214ed7a19d1a7fd9db948c9 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 19 Jan 2026 10:26:37 +0000 Subject: [PATCH 32/34] docs: Use builtin path to Python to set location for CMake --- manual/sphinx/conf.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/manual/sphinx/conf.py b/manual/sphinx/conf.py index 6f2e12f349..98b0f60d06 100755 --- a/manual/sphinx/conf.py +++ b/manual/sphinx/conf.py @@ -72,8 +72,6 @@ def __getattr__(cls, name): sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) print(os.environ) print(sys.argv) - python = sys.argv[0] - pydir = "/".join(python.split("/")[:-2]) os.system("which clang-format") os.system("which clang-format-6.0") subprocess.run("git submodule update --init --recursive", shell=True) @@ -86,7 +84,7 @@ def __getattr__(cls, name): " -DBOUT_UPDATE_GIT_SUBMODULE=OFF" " -DBOUT_TESTS=OFF" " -DBOUT_ALLOW_INSOURCE_BUILD=ON" - f" -DPython3_ROOT_DIR={pydir}" + f" -DPython3_ROOT_DIR={sys.exec_prefix}" ) subprocess.run(f"echo {cmake}", shell=True) subprocess.run(f"{cmake}", shell=True, check=True) From 3252e41690bc0b97b27feb3193220b8ca4e24638 Mon Sep 17 00:00:00 2001 From: Peter Hill Date: Mon, 19 Jan 2026 10:27:36 +0000 Subject: [PATCH 33/34] docs: Remove outdated comment --- manual/sphinx/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/manual/sphinx/conf.py b/manual/sphinx/conf.py index 98b0f60d06..6046173aef 100755 --- a/manual/sphinx/conf.py +++ b/manual/sphinx/conf.py @@ -95,7 +95,6 @@ def __getattr__(cls, name): sys.path.append("bout_build/tools/pylib") -# readthedocs currently runs out of memory if we actually dare to try to do this if has_breathe: # Run doxygen to generate the XML sources if on_readthedocs: From 876fe2c0e77788eae2f58082a80ba7fe42228605 Mon Sep 17 00:00:00 2001 From: ZedThree <1486942+ZedThree@users.noreply.github.com> Date: Mon, 19 Jan 2026 10:28:55 +0000 Subject: [PATCH 34/34] Apply black changes --- bin/bout-add-mod-path | 12 +++---- bin/bout-pylib-cmd-to-bin | 31 ++++++------------- bin/bout-v5-factory-upgrader.py | 21 +++---------- bin/bout-v5-format-upgrader.py | 1 - bin/bout-v5-header-upgrader.py | 7 ++--- bin/bout-v5-input-file-upgrader.py | 6 ++-- bin/bout-v5-macro-upgrader.py | 6 ++-- bin/bout-v5-physics-model-upgrader.py | 13 +++----- bin/bout-v5-xzinterpolation-upgrader.py | 12 ++----- bin/update_version_number_in_files.py | 6 ++-- src/field/gen_fieldops.py | 1 - tests/MMS/GBS/runtest-slab2d | 1 - tests/MMS/GBS/runtest-slab3d | 1 - tests/MMS/advection/runtest | 1 - tests/MMS/diffusion/runtest | 1 - tests/MMS/diffusion2/Z/plot_error.py | 1 + tests/MMS/diffusion2/runtest | 1 - tests/MMS/fieldalign/runtest.broken | 1 - tests/MMS/hw/runtest | 1 - tests/MMS/laplace/runtest | 1 - tests/MMS/spatial/diffusion/runtest | 1 - tests/MMS/wave-1d-y/runtest | 1 - tests/MMS/wave-1d/runtest | 1 - tests/integrated/test-command-args/runtest | 1 - tests/integrated/test-cyclic/runtest | 1 - tests/integrated/test-griddata/runtest | 1 - tests/integrated/test-gyro/runtest | 1 - tests/integrated/test-invpar/runtest | 1 - tests/integrated/test-laplace/runtest | 1 - .../integrated/test-multigrid_laplace/runtest | 1 - .../runtest_multiple_grids | 1 - .../test-multigrid_laplace/runtest_unsheared | 1 - tests/integrated/test-naulin-laplace/runtest | 1 - .../runtest_multiple_grids | 1 - .../test-naulin-laplace/runtest_unsheared | 1 - tests/integrated/test-petsc_laplace/runtest | 1 - .../test-petsc_laplace_MAST-grid/runtest | 1 - tests/integrated/test-region-iterator/runtest | 1 - tests/integrated/test-restarting/runtest | 1 - tests/integrated/test-smooth/runtest | 1 - tests/integrated/test-squash/runtest | 1 - tests/integrated/test-yupdown/runtest | 1 - tools/pylib/_boutpp_build/backend.py | 18 ++++------- 43 files changed, 41 insertions(+), 124 deletions(-) diff --git a/bin/bout-add-mod-path b/bin/bout-add-mod-path index 9faf1be3de..ee7ea66d25 100755 --- a/bin/bout-add-mod-path +++ b/bin/bout-add-mod-path @@ -104,8 +104,7 @@ def create_mod(modulepath, name, top, build): else: prereq = "" with open(filename, "w") as f: - f.write( - f"""#%Module 1.0 + f.write(f"""#%Module 1.0 # # BOUT++ module for use with 'environment-modules' package # Created by bout-add-mod-path v0.9 @@ -119,17 +118,14 @@ setenv BOUT_TOP {top} prepend-path PATH {top}/bin prepend-path PYTHONPATH {top}/tools/pylib prepend-path IDL_PATH +{top}/tools/idllib:'' -""" - ) +""") if build != top: - f.write( - f"""#%Module 1.0 + f.write(f"""#%Module 1.0 setenv BOUT_BUILD {build} prepend-path PATH {build}/bin prepend-path LD_LIBRARY_PATH {build}/lib prepend-path PYTHONPATH {build}/tools/pylib -""" - ) +""") print(f"created `{filename}`") diff --git a/bin/bout-pylib-cmd-to-bin b/bin/bout-pylib-cmd-to-bin index 8f88a5dbf4..8d6dbed7ae 100755 --- a/bin/bout-pylib-cmd-to-bin +++ b/bin/bout-pylib-cmd-to-bin @@ -126,8 +126,7 @@ def createwrapper(mod, func_name, func, name): out += end f.write(out) - fprint( - """#!/usr/bin/env python3 + fprint("""#!/usr/bin/env python3 # PYTHON_ARGCOMPLETE_OK import argparse @@ -136,8 +135,7 @@ try: except ImportError: argcomplete=None -""" - ) +""") doc = True para = False ret = False @@ -183,19 +181,16 @@ except ImportError: arg_help[curarg].append(esc(blas)) # Print functions that are needed if "str_to_slice" in arg_type.values(): - fprint( - """ + fprint(""" def str_to_slice(sstr): args=[] for s in sstr.split(','): args.append(int(s)) print(args) return slice(*args) -""" - ) +""") if "str_to_bool" in arg_type.values(): - fprint( - """ + fprint(""" def str_to_bool(sstr): low=sstr.lower() # no or false @@ -206,8 +201,7 @@ def str_to_bool(sstr): return True else: raise ArgumentTypeError("Cannot parse %s to bool type"%sstr) -""" - ) +""") # Create the parser fprint("parser = argparse.ArgumentParser(%s)" % (esc(docs))) spec = inspect.signature(func) @@ -247,24 +241,19 @@ def str_to_bool(sstr): pre = "\n " fprint(")") - fprint( - """ + fprint(""" if argcomplete: argcomplete.autocomplete(parser) -# late import for faster auto-complete""" - ) +# late import for faster auto-complete""") fprint("from %s import %s" % (mod, func_name)) - fprint( - """ + fprint(""" args = parser.parse_args() # Call the function %s, using command line arguments %s(**args.__dict__) -""" - % (func_name, func_name) - ) +""" % (func_name, func_name)) # alternative, but I think 0o755 is easier to read # import stat # os.chmod(filename,stat.S_IRWXU|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH) diff --git a/bin/bout-v5-factory-upgrader.py b/bin/bout-v5-factory-upgrader.py index 29fc07db30..ee24572a94 100755 --- a/bin/bout-v5-factory-upgrader.py +++ b/bin/bout-v5-factory-upgrader.py @@ -5,7 +5,6 @@ import difflib import re - # Dictionary of factory methods that may need updating factories = { "Interpolation": { @@ -62,9 +61,7 @@ def find_factory_calls(factory, source): \s*=\s* {factory_name}:: .*{create_method}.* - """.format( - **factory - ), + """.format(**factory), source, re.VERBOSE, ) @@ -75,9 +72,7 @@ def find_type_pointers(factory, source): r""" \b{type_name}\s*\*\s* # Type name and pointer ([\w_]+)\s*; # Variable name - """.format( - **factory - ), + """.format(**factory), source, re.VERBOSE, ) @@ -107,9 +102,7 @@ def fix_declarations(factory, variables, source): (.*?)(class\s*)? # optional "class" keyword \b({type_name})\s*\*\s* # Type-pointer ({variable_name})\s*; # Variable - """.format( - type_name=factory["type_name"], variable_name=variable - ), + """.format(type_name=factory["type_name"], variable_name=variable), r"\1std::unique_ptr<\3> \4{nullptr};", source, flags=re.VERBOSE, @@ -123,9 +116,7 @@ def fix_declarations(factory, variables, source): ({variable_name})\s* # Variable =\s* # Assignment from factory ({factory_name}::.*{create_method}.*); - """.format( - variable_name=variable, **factory - ), + """.format(variable_name=variable, **factory), r"\1auto \4 = \5;", source, flags=re.VERBOSE, @@ -139,9 +130,7 @@ def fix_declarations(factory, variables, source): ({variable_name})\s* # Variable =\s* # Assignment (0|nullptr|NULL); - """.format( - variable_name=variable, **factory - ), + """.format(variable_name=variable, **factory), r"\1std::unique_ptr<\2> \3{nullptr};", source, flags=re.VERBOSE, diff --git a/bin/bout-v5-format-upgrader.py b/bin/bout-v5-format-upgrader.py index 7c7d13ac7f..a534ca240a 100755 --- a/bin/bout-v5-format-upgrader.py +++ b/bin/bout-v5-format-upgrader.py @@ -5,7 +5,6 @@ import difflib import re - format_replacements = { "c": "c", "d": "d", diff --git a/bin/bout-v5-header-upgrader.py b/bin/bout-v5-header-upgrader.py index 49a8fbcbe4..77794ab920 100755 --- a/bin/bout-v5-header-upgrader.py +++ b/bin/bout-v5-header-upgrader.py @@ -9,7 +9,6 @@ from typing import List from subprocess import run - header_shim_sentinel = "// BOUT++ header shim" header_warning = f"""\ @@ -122,8 +121,7 @@ def create_patch(filename, original, modified): if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent( - """\ + description=textwrap.dedent("""\ Fix deprecated header locations for BOUT++ v4 -> v5 All BOUT++ headers are now under ``include/bout`` and @@ -142,8 +140,7 @@ def create_patch(filename, original, modified): If you have staged changes, this tool will not work, so to avoid committing undesired or unrelated changes. - """ - ), + """), ) parser.add_argument( diff --git a/bin/bout-v5-input-file-upgrader.py b/bin/bout-v5-input-file-upgrader.py index e2940ff58a..ea979005d5 100755 --- a/bin/bout-v5-input-file-upgrader.py +++ b/bin/bout-v5-input-file-upgrader.py @@ -271,8 +271,7 @@ def possibly_apply_patch(patch, options_file, quiet=False, force=False): if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent( - """\ + description=textwrap.dedent("""\ Fix input files for BOUT++ v5+ Please note that this will only fix input options in sections with @@ -300,8 +299,7 @@ def possibly_apply_patch(patch, options_file, quiet=False, force=False): Files that change in this way will have the "canonicalisation" patch presented first. If you choose not to apply this patch, the "upgrade - fixer" patch will still include it.""" - ), + fixer" patch will still include it."""), ) parser.add_argument("files", action="store", nargs="+", help="Input files") diff --git a/bin/bout-v5-macro-upgrader.py b/bin/bout-v5-macro-upgrader.py index 11b4926255..d644fed9e8 100755 --- a/bin/bout-v5-macro-upgrader.py +++ b/bin/bout-v5-macro-upgrader.py @@ -342,8 +342,7 @@ def create_patch(filename, original, modified): if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent( - """\ + description=textwrap.dedent("""\ Fix macro defines for BOUT++ v4 -> v5 Please note that this is only slightly better than dumb text replacement. It @@ -359,8 +358,7 @@ def create_patch(filename, original, modified): still replace them in strings or comments. Please check the diff output carefully! - """ - ), + """), ) parser.add_argument("files", action="store", nargs="+", help="Input files") diff --git a/bin/bout-v5-physics-model-upgrader.py b/bin/bout-v5-physics-model-upgrader.py index 26fb8ef6e0..260d1d59ee 100755 --- a/bin/bout-v5-physics-model-upgrader.py +++ b/bin/bout-v5-physics-model-upgrader.py @@ -8,7 +8,6 @@ import textwrap import warnings - PHYSICS_MODEL_INCLUDE = '#include "bout/physicsmodel.hxx"' PHYSICS_MODEL_SKELETON = """ @@ -213,13 +212,11 @@ def fix_bout_constrain(source, error_on_warning): "\n ".join(["{}:{}".format(i, source_lines[i]) for i in line_range]) ) - message = textwrap.dedent( - """\ + message = textwrap.dedent("""\ Some uses of `bout_constrain` remain, but we could not automatically convert them to use `Solver::constraint`. Please fix them before continuing: - """ - ) + """) message += " " + "\n ".join(lines_context) if error_on_warning: @@ -389,8 +386,7 @@ def create_patch(filename, original, modified): if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent( - """\ + description=textwrap.dedent("""\ Upgrade legacy physics models to use the PhysicsModel class This will do the bare minimum required to compile, and @@ -403,8 +399,7 @@ def create_patch(filename, original, modified): By default, this will use the file name stripped of file extensions as the name of the new class. Use '--name=' to give a different name. - """ - ), + """), ) parser.add_argument("files", action="store", nargs="+", help="Files to fix") diff --git a/bin/bout-v5-xzinterpolation-upgrader.py b/bin/bout-v5-xzinterpolation-upgrader.py index 37c79e0de8..e70c3c54ae 100755 --- a/bin/bout-v5-xzinterpolation-upgrader.py +++ b/bin/bout-v5-xzinterpolation-upgrader.py @@ -54,9 +54,7 @@ def fix_header_includes(old_header, new_header, source): (<|") ({header}) # Header name (>|") - """.format( - header=old_header - ), + """.format(header=old_header), r"\1\2{header}\4".format(header=new_header), source, flags=re.VERBOSE, @@ -67,9 +65,7 @@ def fix_interpolations(old_interpolation, new_interpolation, source): return re.sub( r""" \b{}\b - """.format( - old_interpolation - ), + """.format(old_interpolation), r"{}".format(new_interpolation), source, flags=re.VERBOSE, @@ -120,9 +116,7 @@ def fix_factories(old_factory, new_factory, source): return re.sub( r""" \b{}\b - """.format( - old_factory - ), + """.format(old_factory), r"{}".format(new_factory), source, flags=re.VERBOSE, diff --git a/bin/update_version_number_in_files.py b/bin/update_version_number_in_files.py index ec9a31bc32..3e9758a8c1 100755 --- a/bin/update_version_number_in_files.py +++ b/bin/update_version_number_in_files.py @@ -158,8 +158,7 @@ def create_patch(filename, original, modified): if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, - description=textwrap.dedent( - """\ + description=textwrap.dedent("""\ Update the software version number to the specified version, to be given in the form major.minor.patch, e.g. 5.10.3 @@ -172,8 +171,7 @@ def create_patch(filename, original, modified): the 'minor' version number of the provided version will be incremented by 1, e.g. 5.10.3 -> 5.11.3 - """ - ), + """), ) parser.add_argument( diff --git a/src/field/gen_fieldops.py b/src/field/gen_fieldops.py index 29631ff7aa..3e07d6fec4 100755 --- a/src/field/gen_fieldops.py +++ b/src/field/gen_fieldops.py @@ -11,7 +11,6 @@ """ - from __future__ import print_function from builtins import object diff --git a/tests/MMS/GBS/runtest-slab2d b/tests/MMS/GBS/runtest-slab2d index 97c7e11459..221c34e815 100755 --- a/tests/MMS/GBS/runtest-slab2d +++ b/tests/MMS/GBS/runtest-slab2d @@ -11,7 +11,6 @@ from boutdata.collect import collect from numpy import sqrt, max, abs, mean, array, log, concatenate - build_and_log("MMS test") diff --git a/tests/MMS/GBS/runtest-slab3d b/tests/MMS/GBS/runtest-slab3d index f193583e47..45acd53af7 100755 --- a/tests/MMS/GBS/runtest-slab3d +++ b/tests/MMS/GBS/runtest-slab3d @@ -14,7 +14,6 @@ from numpy import sqrt, max, abs, mean, array, log, concatenate import pickle - build_and_log("MMS test") # List of NX values to use diff --git a/tests/MMS/advection/runtest b/tests/MMS/advection/runtest index 1290a4c247..9a0a691287 100755 --- a/tests/MMS/advection/runtest +++ b/tests/MMS/advection/runtest @@ -20,7 +20,6 @@ import pickle import time - if __name__ == "__main__": build_and_log("MMS advection") diff --git a/tests/MMS/diffusion/runtest b/tests/MMS/diffusion/runtest index a25b3519a6..ef6b335f70 100755 --- a/tests/MMS/diffusion/runtest +++ b/tests/MMS/diffusion/runtest @@ -15,7 +15,6 @@ from boutdata.collect import collect from numpy import sqrt, max, abs, mean, array, log - build_and_log("MMS diffusion test") # List of NX values to use diff --git a/tests/MMS/diffusion2/Z/plot_error.py b/tests/MMS/diffusion2/Z/plot_error.py index 5c4e1164c1..4b4b666758 100644 --- a/tests/MMS/diffusion2/Z/plot_error.py +++ b/tests/MMS/diffusion2/Z/plot_error.py @@ -4,6 +4,7 @@ @author: yolen """ + import boutdata import matplotlib.pyplot as plt diff --git a/tests/MMS/diffusion2/runtest b/tests/MMS/diffusion2/runtest index 546be3b2c1..d1b8072fc8 100755 --- a/tests/MMS/diffusion2/runtest +++ b/tests/MMS/diffusion2/runtest @@ -20,7 +20,6 @@ from numpy import sqrt, max, abs, mean, array, log from os.path import join - build_and_log("MMS diffusion test") # List of input directories diff --git a/tests/MMS/fieldalign/runtest.broken b/tests/MMS/fieldalign/runtest.broken index e09fbeccd5..bfb2023c1d 100755 --- a/tests/MMS/fieldalign/runtest.broken +++ b/tests/MMS/fieldalign/runtest.broken @@ -18,7 +18,6 @@ from os.path import join import time - build_and_log("MMS test") # nxlist = [256, 128, 64, 32, 16, 8] # do in reverse order to save disk space diff --git a/tests/MMS/hw/runtest b/tests/MMS/hw/runtest index b6abadc3b9..62740fcbbd 100755 --- a/tests/MMS/hw/runtest +++ b/tests/MMS/hw/runtest @@ -15,7 +15,6 @@ from boutdata.collect import collect from numpy import sqrt, max, abs, mean, array, log, concatenate - build_and_log("MMS test") # List of NX values to use diff --git a/tests/MMS/laplace/runtest b/tests/MMS/laplace/runtest index 98eb62da87..80c8bf08af 100755 --- a/tests/MMS/laplace/runtest +++ b/tests/MMS/laplace/runtest @@ -14,7 +14,6 @@ from boutdata.collect import collect from numpy import sqrt, max, abs, mean, array, log, concatenate - build_and_log("MMS test") # List of NX values to use diff --git a/tests/MMS/spatial/diffusion/runtest b/tests/MMS/spatial/diffusion/runtest index 000cf8f09b..8d4e759d59 100755 --- a/tests/MMS/spatial/diffusion/runtest +++ b/tests/MMS/spatial/diffusion/runtest @@ -22,7 +22,6 @@ from os.path import join import matplotlib.pyplot as plt - build_and_log("MMS diffusion test") # List of input directories diff --git a/tests/MMS/wave-1d-y/runtest b/tests/MMS/wave-1d-y/runtest index 9a4de5a3bb..332d6864b0 100755 --- a/tests/MMS/wave-1d-y/runtest +++ b/tests/MMS/wave-1d-y/runtest @@ -20,7 +20,6 @@ from sys import stdout from numpy import sqrt, max, abs, mean, array, log, concatenate, pi - build_and_log("Making MMS wave test") # List of NX values to use diff --git a/tests/MMS/wave-1d/runtest b/tests/MMS/wave-1d/runtest index f13fb7bd11..1adb7c7d6d 100755 --- a/tests/MMS/wave-1d/runtest +++ b/tests/MMS/wave-1d/runtest @@ -15,7 +15,6 @@ from boutdata.collect import collect from numpy import sqrt, max, abs, mean, array, log, concatenate - build_and_log("Making MMS wave test") # List of NX values to use diff --git a/tests/integrated/test-command-args/runtest b/tests/integrated/test-command-args/runtest index 39939bb105..a8dc3f020c 100755 --- a/tests/integrated/test-command-args/runtest +++ b/tests/integrated/test-command-args/runtest @@ -7,7 +7,6 @@ import shutil import unittest import platform - OUTPUT_FILE = "stdout.log" if platform.system() == "FreeBSD" else "stderr.log" diff --git a/tests/integrated/test-cyclic/runtest b/tests/integrated/test-cyclic/runtest index 5e31da6239..c68f9b033e 100755 --- a/tests/integrated/test-cyclic/runtest +++ b/tests/integrated/test-cyclic/runtest @@ -17,7 +17,6 @@ from boututils.run_wrapper import build_and_log, shell, launch from boutdata.collect import collect from sys import stdout, exit - build_and_log("Cyclic Reduction test") flags = ["", "nsys=2", "nsys=5 periodic", "nsys=7 n=10"] diff --git a/tests/integrated/test-griddata/runtest b/tests/integrated/test-griddata/runtest index 1c57bf5be7..6aef955023 100755 --- a/tests/integrated/test-griddata/runtest +++ b/tests/integrated/test-griddata/runtest @@ -13,7 +13,6 @@ from boutdata.collect import collect import numpy as np from sys import stdout, exit - build_and_log("griddata test") for nproc in [1]: diff --git a/tests/integrated/test-gyro/runtest b/tests/integrated/test-gyro/runtest index 52ab0de4ab..7a0209fa57 100755 --- a/tests/integrated/test-gyro/runtest +++ b/tests/integrated/test-gyro/runtest @@ -25,7 +25,6 @@ from boutdata.collect import collect import numpy as np from sys import stdout, exit - build_and_log("Gyro-average inversion test") # Read benchmark values diff --git a/tests/integrated/test-invpar/runtest b/tests/integrated/test-invpar/runtest index de7f028528..53f6015fe9 100755 --- a/tests/integrated/test-invpar/runtest +++ b/tests/integrated/test-invpar/runtest @@ -12,7 +12,6 @@ from boututils.run_wrapper import build_and_log, shell, launch from boutdata.collect import collect from sys import stdout, exit - build_and_log("parallel inversion test") flags_src = [ diff --git a/tests/integrated/test-laplace/runtest b/tests/integrated/test-laplace/runtest index e54e46d0d8..d1e9c3d1c9 100755 --- a/tests/integrated/test-laplace/runtest +++ b/tests/integrated/test-laplace/runtest @@ -41,7 +41,6 @@ from boutdata.collect import collect import numpy as np from sys import stdout, exit - build_and_log("Laplacian inversion test") # Read benchmark values diff --git a/tests/integrated/test-multigrid_laplace/runtest b/tests/integrated/test-multigrid_laplace/runtest index 4a7455f80b..f325185c46 100755 --- a/tests/integrated/test-multigrid_laplace/runtest +++ b/tests/integrated/test-multigrid_laplace/runtest @@ -22,7 +22,6 @@ from boututils.run_wrapper import build_and_log, shell, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("multigrid Laplacian inversion test") print("Running multigrid Laplacian inversion test") diff --git a/tests/integrated/test-multigrid_laplace/runtest_multiple_grids b/tests/integrated/test-multigrid_laplace/runtest_multiple_grids index 6817120b13..739d15f7d4 100755 --- a/tests/integrated/test-multigrid_laplace/runtest_multiple_grids +++ b/tests/integrated/test-multigrid_laplace/runtest_multiple_grids @@ -18,7 +18,6 @@ from boututils.run_wrapper import shell, build_and_log, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("Multigrid Laplacian inversion test") print("Running multigrid Laplacian inversion test") diff --git a/tests/integrated/test-multigrid_laplace/runtest_unsheared b/tests/integrated/test-multigrid_laplace/runtest_unsheared index cda68f2167..d0dca3a808 100755 --- a/tests/integrated/test-multigrid_laplace/runtest_unsheared +++ b/tests/integrated/test-multigrid_laplace/runtest_unsheared @@ -18,7 +18,6 @@ from boututils.run_wrapper import shell, build_and_log, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("Making multigrid Laplacian inversion test") print("Running multigrid Laplacian inversion test") diff --git a/tests/integrated/test-naulin-laplace/runtest b/tests/integrated/test-naulin-laplace/runtest index f972eab6cc..145257c23b 100755 --- a/tests/integrated/test-naulin-laplace/runtest +++ b/tests/integrated/test-naulin-laplace/runtest @@ -22,7 +22,6 @@ from boututils.run_wrapper import build_and_log, shell, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("LaplaceNaulin inversion test") print("Running LaplaceNaulin inversion test") diff --git a/tests/integrated/test-naulin-laplace/runtest_multiple_grids b/tests/integrated/test-naulin-laplace/runtest_multiple_grids index c0281c3a4e..f56a80677e 100755 --- a/tests/integrated/test-naulin-laplace/runtest_multiple_grids +++ b/tests/integrated/test-naulin-laplace/runtest_multiple_grids @@ -18,7 +18,6 @@ from boututils.run_wrapper import shell, build_and_log, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("Making LaplaceNaulin inversion test") print("Running LaplaceNaulin inversion test") diff --git a/tests/integrated/test-naulin-laplace/runtest_unsheared b/tests/integrated/test-naulin-laplace/runtest_unsheared index 8f47f33026..a845a9d92f 100755 --- a/tests/integrated/test-naulin-laplace/runtest_unsheared +++ b/tests/integrated/test-naulin-laplace/runtest_unsheared @@ -18,7 +18,6 @@ from boututils.run_wrapper import shell, build_and_log, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("LaplaceNaulin inversion test") print("Running LaplaceNaulin inversion test") diff --git a/tests/integrated/test-petsc_laplace/runtest b/tests/integrated/test-petsc_laplace/runtest index ac248c4ce7..83e1006338 100755 --- a/tests/integrated/test-petsc_laplace/runtest +++ b/tests/integrated/test-petsc_laplace/runtest @@ -30,7 +30,6 @@ from boutdata.collect import collect # import numpy as np from sys import stdout, exit - build_and_log("PETSc Laplacian inversion test") print("Running PETSc Laplacian inversion test") diff --git a/tests/integrated/test-petsc_laplace_MAST-grid/runtest b/tests/integrated/test-petsc_laplace_MAST-grid/runtest index 5a4cbf875a..3be39949c3 100755 --- a/tests/integrated/test-petsc_laplace_MAST-grid/runtest +++ b/tests/integrated/test-petsc_laplace_MAST-grid/runtest @@ -28,7 +28,6 @@ from boututils.run_wrapper import build_and_log, shell, launch_safe from boutdata.collect import collect from sys import stdout, exit - build_and_log( "PETSc Laplacian inversion test with non-identity metric (taken from grid for MAST SOL)" ) diff --git a/tests/integrated/test-region-iterator/runtest b/tests/integrated/test-region-iterator/runtest index e5825285de..2277ef15e9 100755 --- a/tests/integrated/test-region-iterator/runtest +++ b/tests/integrated/test-region-iterator/runtest @@ -17,7 +17,6 @@ from boututils.run_wrapper import build_and_log, launch_safe from boutdata.collect import collect from sys import exit - build_and_log("Region Iterator test") flags = [""] diff --git a/tests/integrated/test-restarting/runtest b/tests/integrated/test-restarting/runtest index 262aa818b6..daf19ebac6 100755 --- a/tests/integrated/test-restarting/runtest +++ b/tests/integrated/test-restarting/runtest @@ -5,7 +5,6 @@ from boutdata.collect import collect import numpy as np from sys import stdout, exit - build_and_log("restart test") # Run once for 10 timesteps diff --git a/tests/integrated/test-smooth/runtest b/tests/integrated/test-smooth/runtest index bd7296341a..91ae793164 100755 --- a/tests/integrated/test-smooth/runtest +++ b/tests/integrated/test-smooth/runtest @@ -16,7 +16,6 @@ from boutdata.collect import collect import numpy as np from sys import stdout, exit - build_and_log("smoothing operator test") # Read benchmark values diff --git a/tests/integrated/test-squash/runtest b/tests/integrated/test-squash/runtest index 2f35e00589..8bf358ee8e 100755 --- a/tests/integrated/test-squash/runtest +++ b/tests/integrated/test-squash/runtest @@ -9,7 +9,6 @@ import argparse import re import os.path - # requires: all_tests # requires: netcdf # cores: 4 diff --git a/tests/integrated/test-yupdown/runtest b/tests/integrated/test-yupdown/runtest index 34fcd36496..13d7365b53 100755 --- a/tests/integrated/test-yupdown/runtest +++ b/tests/integrated/test-yupdown/runtest @@ -6,7 +6,6 @@ from sys import exit from numpy import max, abs - build_and_log("parallel slices test") failed = False diff --git a/tools/pylib/_boutpp_build/backend.py b/tools/pylib/_boutpp_build/backend.py index 6455c203ad..9e305b3048 100755 --- a/tools/pylib/_boutpp_build/backend.py +++ b/tools/pylib/_boutpp_build/backend.py @@ -212,12 +212,10 @@ def build_sdist(sdist_directory, config_settings=None): run(f"rm {tmp}") with open(tmp, "w") as f: - f.write( - f"""Metadata-Version: 2.1 + f.write(f"""Metadata-Version: 2.1 Name: {pkgname} Version: {getversion()} -""" - ) +""") with open("LICENSE") as src: pre = "License: " for l in src: @@ -269,23 +267,19 @@ def prepare_metadata_for_build_wheel( distinfo = f"{metadata_directory}/{thisdir}" mkdir_p(distinfo) with open(f"{distinfo}/METADATA", "w") as f: - f.write( - f"""Metadata-Version: 2.1 + f.write(f"""Metadata-Version: 2.1 Name: {pkgname} Version: {getversion()} License-File: COPYING -""" - ) +""") run(f"cp LICENSE {distinfo}/COPYING") run(f"cp LICENSE.GPL {distinfo}/COPYING.GPL") with open(f"{distinfo}/WHEEL", "w") as f: - f.write( - f"""Wheel-Version: 1.0 + f.write(f"""Wheel-Version: 1.0 Generator: boutpp_custom_build_wheel ({getversion()}) Root-Is-Purelib: false Tag: {gettag()} -""" - ) +""") if record: with open(f"{distinfo}/RECORD", "w") as f: