diff --git a/dynare++/kord/journal.hh b/dynare++/kord/journal.hh index 63b77a9b931fcbb94424c42b88e1c02cfc6853c3..58ce81772e627be1ea6377832fba466a68ca2b10 100644 --- a/dynare++/kord/journal.hh +++ b/dynare++/kord/journal.hh @@ -1,6 +1,6 @@ /* * Copyright © 2004 Ondra Kamenik - * Copyright © 2019 Dynare Team + * Copyright © 2019-2020 Dynare Team * * This file is part of Dynare. * @@ -57,14 +57,18 @@ struct SystemResources class Journal : public std::ofstream { - int ord; - int depth; + int ord{0}; + int depth{0}; public: explicit Journal(const std::string &fname) - : std::ofstream(fname), ord(0), depth(0) + : std::ofstream(fname) { printHeader(); } + /* Constructor that does not initialize the std::ofstream. To be used when an + on-disk journal is not wanted. */ + Journal() = default; + Journal &operator=(Journal &&) = default; ~Journal() override { flush(); diff --git a/mex/sources/k_order_perturbation/k_order_perturbation.cc b/mex/sources/k_order_perturbation/k_order_perturbation.cc index 4ae1151db72937c7deccb497838701d172c7a75b..c091db33993d7dd52bfc88d2c8c6b5fa273d00ff 100644 --- a/mex/sources/k_order_perturbation/k_order_perturbation.cc +++ b/mex/sources/k_order_perturbation/k_order_perturbation.cc @@ -121,6 +121,11 @@ extern "C" { mexErrMsgTxt("options_.threads.k_order_perturbation be a numeric scalar"); int num_threads = static_cast<int>(mxGetScalar(num_threads_mx)); + const mxArray *debug_mx = mxGetField(options_mx, 0, "debug"); + if (!(debug_mx && mxIsLogicalScalar(debug_mx))) + mexErrMsgTxt("options_.debug should be a logical scalar"); + bool debug = static_cast<bool>(mxGetScalar(debug_mx)); + // Extract various fields from M_ const mxArray *fname_mx = mxGetField(M_mx, 0, "fname"); if (!(fname_mx && mxIsChar(fname_mx) && mxGetM(fname_mx) == 1)) @@ -197,7 +202,10 @@ extern "C" { try { - Journal journal(fname + ".jnl"); + // Journal is not written on-disk, unless options_.debug = true (see #1735) + Journal journal; + if (debug) + journal = Journal{fname + ".jnl"}; std::unique_ptr<DynamicModelAC> dynamicModelFile; if (use_dll)