Skip to content

Commit

Permalink
- stop the simulation, if an error occurs
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11305 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Mar 5, 2012
1 parent 285bca3 commit c9c77b7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
9 changes: 6 additions & 3 deletions SimulationRuntime/c/math-support/initialization.c
Expand Up @@ -503,7 +503,10 @@ static void NelderMeadOptimization(long N,
else
{
/* not possible to be here */
INFO("not possible to be here");
WARNING1("fxr = %g", fxr);
WARNING1("fxk = %g", fxk);

THROW("undefined error in NelderMeadOptimization");
}
}while(1.0);

Expand Down Expand Up @@ -1014,8 +1017,8 @@ static int none_initialization(DATA *data, int updateStartValues)
setAllParamsToStart(data);
if(updateStartValues)
{
updateBoundStartValues(data);
updateBoundParameters(data);
updateBoundStartValues(data);
}

/* initialize all relations that are ZeroCrossings */
Expand Down Expand Up @@ -1073,8 +1076,8 @@ static int state_initialization(DATA *data, int optiMethod, int updateStartValue
setAllParamsToStart(data);
if(updateStartValues)
{
updateBoundStartValues(data);
updateBoundParameters(data);
updateBoundStartValues(data);
}

/* initialize all relations that are ZeroCrossings */
Expand Down
14 changes: 6 additions & 8 deletions SimulationRuntime/c/util/division.c
Expand Up @@ -33,15 +33,13 @@
#include <stdlib.h>

#include "division.h"
#include "error.h"

int encounteredDivisionByZero = 0;

modelica_real division_error(modelica_real b, const char* division_str)
modelica_real division_error(modelica_real b, const char* division_str, const char* file, long line)
{
if(!encounteredDivisionByZero) {
fprintf(stderr, "ERROR: Division by zero in partial equation: %s.\n",division_str); fflush(stderr);
encounteredDivisionByZero = 1;
}
WARNING1("division by zero in partial equation: %s", division_str);
WARNING_AL2("[line] %ld | [file] %s", line, file);
THROW("division by zero");

return b;
}

4 changes: 2 additions & 2 deletions SimulationRuntime/c/util/division.h
Expand Up @@ -35,9 +35,9 @@

#include "openmodelica.h"

#define DIVISION(a,b,c) (((b) != 0) ? ((a) / (b)) : ((a) / division_error(b,c)))
#define DIVISION(a,b,c) (((b) != 0) ? ((a) / (b)) : ((a) / division_error(b, c, __LINE__, __FILE__)))


modelica_real division_error(modelica_real b, const char* division_str);
modelica_real division_error(modelica_real b, const char* division_str, const char* file, long line);

#endif

0 comments on commit c9c77b7

Please sign in to comment.