diff --git a/include/amici/model_state.h b/include/amici/model_state.h index 8985ddbf3b..945c33ce03 100644 --- a/include/amici/model_state.h +++ b/include/amici/model_state.h @@ -208,8 +208,6 @@ struct ModelStateDerived { * We could pass the solver's context to the model during initialize() and * only create ModelStateDerived there, but this caused issue in tests with * FSA for unclear reasons. - * TODO: Do we need to attach an error handler here? Not sure if - * NVector and SUNMatrix would even use it. */ sundials::Context sunctx_; diff --git a/include/amici/serialization.h b/include/amici/serialization.h index 7c792b4bcd..5b3c48b3ea 100644 --- a/include/amici/serialization.h +++ b/include/amici/serialization.h @@ -19,8 +19,13 @@ #include #include -/** @file serialization.h Helper functions and forward declarations for - * boost::serialization */ +/** + * @file serialization.h Helper functions and forward declarations for + * boost::serialization + * + * FIXME: Many of the serialization functions seem to be outdated and miss + * some fields. + */ namespace boost { namespace serialization { @@ -284,6 +289,10 @@ void serialize( /** * @brief Serialize AmiVector to a boost archive + * + * NOTE: The deserialized AmiVector/NVector will not have a valid SUNContext. + * This needs to be set afterwards. + * * @param ar archive * @param v AmiVector */ @@ -294,14 +303,9 @@ void serialize( if (Archive::is_loading::value) { std::vector tmp; ar & tmp; - // TODO: how do we get a new sunctx in here?? - // for now, create one for construction of the vector, set it to - // nullptr sundials::Context sunctx; v = amici::AmiVector(tmp, sunctx); - if (v.getNVector()) { - v.getNVector()->sunctx = nullptr; - } + v.set_ctx(sunctx); } else { auto tmp = v.getVector(); ar & tmp; diff --git a/src/solver.cpp b/src/solver.cpp index 961d285f8e..52f26423d7 100644 --- a/src/solver.cpp +++ b/src/solver.cpp @@ -30,7 +30,7 @@ void wrapErrHandlerFn( #ifdef NDEBUG snprintf(msg_buffer, BUF_SIZE, "%s:%d: %s (%d)", file, line, msg, err_code); #else - snprintf(buffer, BUF_SIZE, "%s", msg); + snprintf(msg_buffer, BUF_SIZE, "%s", msg); #endif // we need a matlab-compatible message ID // i.e. colon separated and only [A-Za-z0-9_]