2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2011 - DIGITEO - Cedric DELAMARRE
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 /*--------------------------------------------------------------------------*/
14 #include "checkodeerror.hxx"
19 #include "localization.h"
20 #include "configvariable_interface.h"
22 // return 0 = ok, return 1 = error, return 2 = warning
23 int checkOdeError(int meth, int istate)
32 sciprint(_("Work space insufficient to finish (see messages).\n"));
36 case 1 : // lsode | lsodi (adams)
37 case 2 : // lsode | lsodi (stiff)
41 sciprint(_("Excess work done on this call (perhaps wrong jacobian type).\n"));
44 else if (istate == -2)
46 sciprint(_("Excess accuracy requested (tolerances too small).\n"));
49 else if (istate == -3)
51 sciprint(_("Illegal input detected (see printed message).\n"));
54 else if (istate == -4)
56 sciprint(_("Repeated error test failures (check all inputs).\n"));
59 else if (istate == -5)
61 sciprint(_("Repeated convergence failures (perhaps bad jacobian supplied or wrong choice of jacobian type or tolerances).\n"));
64 else if (istate == -6)
66 sciprint(_("Error weight became zero during problem. (solution component i vanished, and atol or atol(i) = 0.)\n"));
69 else if (istate == -7) // only used with impl (lsodi)
71 sciprint(_("The user-supplied subroutine res set its error flag (ires = 3) despite repeated tries by lsodi to avoid that condition.\n"));
74 else if (istate == -8) // only used with impl (lsodi)
76 sciprint(_("istate was 0 on input but lsodi was unable to compute the initial value of dy/dt.\n"));
81 case 4 : // lsdisc (discrete)
83 if (istate < 0) // from lsdisc.f :
85 // istate = 2 if lsdisc was successful, negative otherwise...
90 case 5 : // lsrgk (rk)
92 if (istate == -1) // from lsrgk.f
98 case 6 : // rkf45 (rkf)
104 if (getWarningMode())
106 sciprint(_("Integration was not completed because relative error tolerance was too small. rerr has been increased appropriately for continuing.\n"));
112 if (getWarningMode())
114 sciprint(_("Integration was not completed because more than 3000 derivative evaluations were needed. This is approximately 500 steps.\n"));
120 sciprint(_("Integration was not completed because solution vanished making a pure relative error test impossible. Must use non-zero aerr to continue. Using the one-step integration mode for one step is a good way to proceed.\n"));
125 sciprint(_("Integration was not completed because requested accuracy could not be achieved using smallest allowable stepsize. User must increase the error tolerance before continued integration can be attempted.\n"));
130 sciprint(_("It is likely that rkf45 is inefficient for solving this problem. Too much output is restricting the natural stepsize choice. Use the one-step integrator mode.\n"));
135 sciprint(_("invalid input parameters : atol and rtol must be greater than 0.\n"));
143 case 7 : // rksimp (fix)
149 else if (istate == 4)
151 sciprint(_("Inappropriate error tolerance.\n"));
160 int checkError(int idid, std::string strName)
164 case 4 ://Only used in dasrt
166 //One or more root found at t
169 case 3 ://The integration to TOUT was successfully completed (T=TOUT) by
171 //stepping past TOUT. Y,ydot are obtained by interpolation.
174 case 2 : //The integration to TSTOP was successfully completed (T=TSTOP)
178 case 1 : //A step was successfully taken in the intermediate-output mode.
180 //The code has not yet reached TOUT.
183 case -1 : //A large amount of work has been expended (About 500 steps)
185 if (getWarningMode())
187 sciprint(_("To many steps necessary to reached next required time discretization point. Change discretisation of time vector t or decrease accuracy.\n"));
191 case -2 : //The error tolerances are too stringent.
193 sciprint(_("The error tolerances are too stringent.\n"));
198 //The local error test cannot be satisfied because you specified
199 //a zero component in ATOL and the corresponding computed solution
200 //component is zero. Thus, a pure relative error test is impossible
201 //for this component.
202 if (getWarningMode())
204 sciprint(_("Atol and computed test value are zero.\n"));
208 case -5 : // only used in daskr
210 // There were repeated failures in the evaluation
211 // or processing of the preconditioner (in JAC).
212 sciprint(_("Cannot evaluate the preconditioner.\n"));
215 case -6 : //Repeated error test failures on the last attempted step.
217 if (getWarningMode())
219 sciprint(_("A singularity in the solution may be present.\n"));
223 case -7 : //The corrector could not converge.
225 if (getWarningMode())
227 sciprint(_("May be inaccurate or ill-conditioned JACOBIAN.\n"));
231 case -8 : //The matrix of partial derivatives is singular.
233 sciprint(_("Singular partial derivatives matrix (may be redundant equations).\n"));
236 case -9 : //The corrector could not converge.
238 //There were repeated error test failures in this step.
239 if (getWarningMode())
241 sciprint(_("Either ill-posed problem or discontinuity or singularity encountered.\n"));
247 if (getWarningMode())
249 sciprint(_("External ''res'' return many times with ires=-1.\n"));
253 case -11 : //IRES equal to -2 was encountered and
255 //control is being returned to the calling program.
256 sciprint(_("Error in external ''res''.\n"));
259 case -12 : //DDASSL, dasrt or daskr failed to compute the initial YPRIME.
261 sciprint(_("failed to compute the initial Ydot.\n"));
264 case -13 : // only used in daskr
266 // An unrecoverable error was encountered inside the user's PSOL routine,
267 // and control is being returned to the calling program.
268 sciprint(_("Error in external psol.\n"));
271 case -14 : // only used in daskr
273 // The Krylov linear system solver could not achieve convergence.
274 sciprint(_("The Krylov linear system did not converge.\n"));
279 //The code has encountered trouble from which
280 //it cannot recover. A message is printed
281 //explaining the trouble and control is returned
282 //to the calling program. For example, this occurs
283 //when invalid input is detected.
284 if (getWarningMode())
286 sciprint(_("%s encountered trouble.\n"), strName.c_str());