Skip to content

Commit

Permalink
Env Variable: AMREX_DEBUG
Browse files Browse the repository at this point in the history
Introduce control of backtrace handling and exception throwing via
the environment variable `AMREX_DEBUG`.

This is very handly when running CI/CD and IDE workflows to quickly
debug a failing test without overwriting default init parameters.
  • Loading branch information
ax3l committed Sep 23, 2024
1 parent 84c7ade commit 06e4f30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Docs/sphinx_documentation/source/Debugging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ The following runtime options need to be set in order to prevent AMReX from catc

This default behavior can also be modified by applications, see for example `this custom application initializer <https://github.com/Exawind/amr-wind/blob/84f81a990152f4f748c1ab0fa17c8c663e51df86/amr-wind/main.cpp#L21>`__.

The above default can also be achieve by setting the environment variable ``AMREX_DEBUG``:
Alternatively, set the environment variable ``AMREX_DEBUG`` to change the defaults in the same way:

.. highlight:: console

::
.. code-block: console
export AMREX_DEBUG=1
Note that input and command line arguments always have precedence over environment variables.


.. _sec:gpu:debugging:

Expand Down
5 changes: 2 additions & 3 deletions Src/Base/AMReX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include <cfenv>
#endif

#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
Expand Down Expand Up @@ -339,7 +340,7 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
bool amrex_debug = false;
if (env_amrex_debug != nullptr) {
std::string str_amrex_debug{env_amrex_debug};
for(auto& c : test) { c = tolower(c); }
for(auto& c : str_amrex_debug) { c = std::tolower(c); }

if (str_amrex_debug == "1" || str_amrex_debug == "on" || str_amrex_debug == "true") {
amrex_debug = true;
Expand All @@ -349,8 +350,6 @@ amrex::Initialize (int& argc, char**& argv, bool build_parm_parse,
system::exename.clear();
// system::verbose = 0;
system::regtest_reduction = false;


system::signal_handling = !amrex_debug;
system::handle_sigsegv = true;
system::handle_sigterm = false;
Expand Down

0 comments on commit 06e4f30

Please sign in to comment.