Skip to content

Commit 74c37fd

Browse files
author
Yi Zhang
committed
cleanup
1 parent ee568be commit 74c37fd

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

stan/math/prim/err/check_flag_sundials.hpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef STAN_MATH_PRIM_ERR_CHECK_FLAG_SUNDIALS_HPP
22
#define STAN_MATH_PRIM_ERR_CHECK_FLAG_SUNDIALS_HPP
33

4-
#include <kinsol/kinsol.h>
5-
#include <cvodes/cvodes.h>
64
#include <stan/math/prim/meta.hpp>
75
#include <stan/math/prim/err/domain_error.hpp>
6+
#include <kinsol/kinsol.h>
7+
#include <cvodes/cvodes.h>
88

99
namespace stan {
1010
namespace math {
@@ -196,18 +196,16 @@ inline void cvodes_check(int flag, const char* func_name) {
196196

197197
/**
198198
* Throws an exception message when the functions in KINSOL
199-
* fails. When the exception is caused
200-
* by a tuning parameter the user controls, gives a specific
201-
* error. "KINGetReturnFlagName()" from sundials has a mem leak bug so
199+
* fails. "KINGetReturnFlagName()" from SUNDIALS has a mem leak bug so
202200
* until it's fixed we cannot use it to extract flag error string.
203201
*
204202
* @param flag Error flag
205203
* @param func_name calling function name
206204
* @throw <code>std::runtime_error</code> if the flag is negative.
207205
*/
208206
inline void kinsol_check(int flag, const char* func_name) {
209-
std::ostringstream ss;
210207
if (flag < 0) {
208+
std::ostringstream ss;
211209
ss << "algebra_solver failed with error flag " << flag << ".";
212210
throw std::runtime_error(ss.str());
213211
}
@@ -221,10 +219,10 @@ inline void kinsol_check(int flag, const char* func_name) {
221219
*
222220
* @param flag Error flag
223221
* @param func_name calling function name
224-
* @param max_num_steps max number of nonlinear iters
222+
* @param max_num_steps max number of nonlinear iterations.
225223
* @throw <code>std::runtime_error</code> if the flag is negative.
226224
* @throw <code>std::domain_error</code> if the flag indicates max
227-
* number of steps is exceeded..
225+
* number of steps is exceeded.
228226
*/
229227
inline void kinsol_check(int flag, const char* func_name,
230228
long int max_num_steps) { // NOLINT(runtime/int)

stan/math/rev/functor/cvodes_utils.hpp

-14
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,9 @@
1010
namespace stan {
1111
namespace math {
1212

13-
// extern "C" inline void cvodes_err_handler(int error_code, const char* module,
14-
// const char* function, char* msg,
15-
// void* eh_data) {
16-
// if (error_code != CV_TOO_MUCH_WORK) {
17-
// std::ostringstream msg1;
18-
// msg1 << msg << " Error code: ";
19-
20-
// throw_domain_error(module, function, error_code, msg1.str().c_str());
21-
// }
22-
// }
23-
2413
inline void cvodes_set_options(void* cvodes_mem,
2514
// NOLINTNEXTLINE(runtime/int)
2615
long int max_num_steps) {
27-
// forward CVode errors to noop error handler
28-
// CVodeSetErrHandlerFn(cvodes_mem, cvodes_err_handler, nullptr);
29-
3016
// Initialize solver parameters
3117
CHECK_CVODES_CALL(CVodeSetMaxNumSteps(cvodes_mem, max_num_steps));
3218

0 commit comments

Comments
 (0)