Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix capturing SUNDIALS warnings after 7.1.1 upgrade #2551

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ThirdParty/sundials/src/cvodes/cvodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -9930,6 +9930,8 @@ void cvProcessError(CVodeMem cv_mem, int error_code, int line, const char* func,
break;
}

/* AMICI: https://github.com/AMICI-dev/AMICI/issues/2550 */
#ifdef AMICI_SUNLOGGER_WARNINGS
if (error_code == CV_WARNING)
{
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_WARNING
Expand All @@ -9940,6 +9942,7 @@ void cvProcessError(CVodeMem cv_mem, int error_code, int line, const char* func,
#endif
break;
}
#endif

/* Call the SUNDIALS main error handler */
SUNHandleErrWithMsg(line, func, file, msg, error_code, cv_mem->cv_sunctx);
Expand Down
3 changes: 3 additions & 0 deletions ThirdParty/sundials/src/idas/idas.c
Original file line number Diff line number Diff line change
Expand Up @@ -8779,6 +8779,8 @@ void IDAProcessError(IDAMem IDA_mem, int error_code, int line, const char* func,
break;
}

/* AMICI: https://github.com/AMICI-dev/AMICI/issues/2550 */
#ifdef AMICI_SUNLOGGER_WARNINGS
if (error_code == IDA_WARNING)
{
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_WARNING
Expand All @@ -8789,6 +8791,7 @@ void IDAProcessError(IDAMem IDA_mem, int error_code, int line, const char* func,
#endif
break;
}
#endif

/* Call the SUNDIALS main error handler */
SUNHandleErrWithMsg(line, func, file, msg, error_code, IDA_mem->ida_sunctx);
Expand Down
1 change: 1 addition & 0 deletions include/amici/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ constexpr double pi = M_PI;
//
// NOTE: When adding / removing / renaming return codes,
// please update simulation_status_to_str_map in amici.h
constexpr int AMICI_WARNING= 99;
constexpr int AMICI_RECOVERABLE_ERROR= 1;
constexpr int AMICI_UNRECOVERABLE_ERROR= -10;
constexpr int AMICI_TOO_MUCH_WORK= -1;
Expand Down
1 change: 1 addition & 0 deletions src/amici.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ std::map<int, std::string> simulation_status_to_str_map = {
{AMICI_NOT_RUN, "AMICI_NOT_RUN"},
{AMICI_LSETUP_FAIL, "AMICI_LSETUP_FAIL"},
{AMICI_FIRST_QRHSFUNC_ERR, "AMICI_FIRST_QRHSFUNC_ERR"},
{AMICI_WARNING, "AMICI_WARNING"},
};

std::unique_ptr<ReturnData> runAmiciSimulation(
Expand Down
2 changes: 1 addition & 1 deletion src/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void wrapErrHandlerFn(
std::is_same<SUNErrCode, int>::value, "Must update format string"
);
// for debug builds, include full file path and line numbers
#ifdef NDEBUG
#ifndef NDEBUG
snprintf(msg_buffer, BUF_SIZE, "%s:%d: %s (%d)", file, line, msg, err_code);
#else
snprintf(msg_buffer, BUF_SIZE, "%s", msg);
Expand Down
4 changes: 4 additions & 0 deletions src/solver_cvodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ static_assert(
amici::AMICI_FIRST_QRHSFUNC_ERR == CV_FIRST_QRHSFUNC_ERR,
"AMICI_FIRST_QRHSFUNC_ERR != CV_FIRST_QRHSFUNC_ERR"
);
static_assert(
amici::AMICI_WARNING == CV_WARNING,
"AMICI_WARNING != CV_WARNING"
);

/*
* The following static members are callback function to CVODES.
Expand Down
4 changes: 4 additions & 0 deletions src/solver_idas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ static_assert(
amici::AMICI_IDAS_CONSTR_FAIL == IDA_CONSTR_FAIL,
"AMICI_IDAS_CONSTR_FAIL != IDA_CONSTR_FAIL"
);
static_assert(
amici::AMICI_WARNING == IDA_WARNING,
"AMICI_WARNING != IDA_WARNING"
);

/*
* The following static members are callback function to IDAS.
Expand Down
Loading