Skip to content

Commit

Permalink
Implemented flags for controlling simulation error messages (log)
Browse files Browse the repository at this point in the history
Fixed bugs (chaanged getExtendsModifierValues, setExtendsModifierValues) 

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2615 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Nov 20, 2006
1 parent 1fe2455 commit ddb2c96
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
31 changes: 21 additions & 10 deletions Compiler/Interactive.mo
Expand Up @@ -1222,7 +1222,7 @@ algorithm
local
Absyn.Program newp,p,p_1,p1;
String resstr,ident,filename,cmt,variability,causality,name,value,top_names_str;
Absyn.ComponentRef class_,subident,comp_ref,cr;
Absyn.ComponentRef class_,subident,comp_ref,cr,crident;
Absyn.Modification mod;
InteractiveSymbolTable st, newst;
list<SCode.Class> s;
Expand All @@ -1237,10 +1237,10 @@ algorithm
case
(ISTMTS(interactiveStmtLst =
{IEXP(exp = Absyn.CALL(function_ =
Absyn.CREF_IDENT(name = "setExtendsModifierValue"),
functionArgs = Absyn.FUNCTIONARGS(args =
Absyn.CREF_IDENT(name = "setExtendsModifierValue"),functionArgs = Absyn.FUNCTIONARGS(args =
{Absyn.CREF(componentReg = class_),
Absyn.CREF(componentReg = Absyn.CREF_QUAL(name = ident,componentRef = subident)),
Absyn.CREF(componentReg = crident),
Absyn.CREF(componentReg = subident),
Absyn.CODE(code = Absyn.C_MODIFICATION(modification = mod))},argNames = {})))}),
(st as SYMBOLTABLE(
ast = p,
Expand All @@ -1250,7 +1250,7 @@ algorithm
compiledFunctions = cf,
loadedFiles = lf)))
equation
(newp,resstr) = setExtendsModifierValue(class_, Absyn.CREF_IDENT(ident,{}), subident, mod, p);
(newp,resstr) = setExtendsModifierValue(class_, crident, subident, mod, p);
then
(resstr,SYMBOLTABLE(newp,s,ic,iv,cf,lf));
case (ISTMTS(interactiveStmtLst = {IEXP(exp = Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "getExtendsModifierNames"),functionArgs = Absyn.FUNCTIONARGS(args = {Absyn.CREF(componentReg = class_),Absyn.CREF(componentReg = ident)},argNames = {})))}),(st as SYMBOLTABLE(ast = p,explodedAst = s,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)))
Expand All @@ -1259,9 +1259,9 @@ algorithm
resstr = getExtendsModifierNames(class_, ident, p);
then
(resstr,st);
case (ISTMTS(interactiveStmtLst = {IEXP(exp = Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "getExtendsModifierValue"),functionArgs = Absyn.FUNCTIONARGS(args = {Absyn.CREF(componentReg = class_),Absyn.CREF(componentReg = Absyn.CREF_QUAL(name = ident,componentRef = subident))},argNames = {})))}),(st as SYMBOLTABLE(ast = p,explodedAst = s,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)))
case (ISTMTS(interactiveStmtLst = {IEXP(exp = Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "getExtendsModifierValue"),functionArgs = Absyn.FUNCTIONARGS(args = {Absyn.CREF(componentReg = class_),Absyn.CREF(componentReg = crident),Absyn.CREF(componentReg = subident)},argNames = {})))}),(st as SYMBOLTABLE(ast = p,explodedAst = s,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)))
equation
resstr = getExtendsModifierValue(class_, Absyn.CREF_IDENT(ident,{}), subident, p);
resstr = getExtendsModifierValue(class_, crident, subident, p);
then
(resstr,st);
case (ISTMTS(interactiveStmtLst = {IEXP(exp = Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "getComponentModifierNames"),functionArgs = Absyn.FUNCTIONARGS(args = {Absyn.CREF(componentReg = class_),Absyn.CREF(componentReg = ident)},argNames = {})))}),(st as SYMBOLTABLE(ast = p,explodedAst = s,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)))
Expand Down Expand Up @@ -4581,7 +4581,7 @@ algorithm
env2 := Env.openScope(env_1, encflag, SOME(id));
ci_state := ClassInf.start(restr, id);
/* Use partial instantiation. Env is only used to retrieve class names not lookup variables
therefore OK.*/
therefore OK. */
(_,env_2,_) := Inst.partialInstClassIn(Env.emptyCache,env2, Types.NOMOD(), Prefix.NOPRE(), Connect.emptySet,
ci_state, cl, false, {});
end getClassEnvNoElaboration;
Expand Down Expand Up @@ -4640,7 +4640,7 @@ algorithm
dyn_ref, causality);
newp = updateProgram(Absyn.PROGRAM({cdef_1},within_), p);
then
("Ok",newp);
("Ok",newp);
case (_,_,_,_,_,_,_,_,_,p) then ("Error",p);
end matchcontinue;
end setComponentProperties;
Expand Down Expand Up @@ -4704,7 +4704,7 @@ protected function setComponentPropertiesInClassparts "function: setComponentPro
bool list, /* dynamic_ref, two booleans */
string) /* causality */
outputs: Absyn.ClassPart list
"
"
input list<Absyn.ClassPart> inAbsynClassPartLst1;
input Absyn.Ident inIdent2;
input Boolean inBoolean3;
Expand Down Expand Up @@ -6620,6 +6620,17 @@ algorithm
res = Dump.printExpStr(exp);
then
res;
case (class_,name,p)
equation
p_class = Absyn.crefToPath(class_);
Absyn.IDENT(name) = Absyn.crefToPath(name);
cdef = getPathedClassInProgram(p_class, p);
comps = getComponentsInClass(cdef);
compelts = Util.listMap(comps, getComponentitemsInElement);
compelts_1 = Util.listFlatten(compelts);
{compitem} = Util.listSelect1(compelts_1, name, componentitemNamed);
failure(_ = getVariableBindingInComponentitem(compitem));
then "";
case (_,_,_) then "Error";
end matchcontinue;
end getComponentBinding;
Expand Down
6 changes: 3 additions & 3 deletions c_runtime/matrix.h
Expand Up @@ -97,13 +97,13 @@ void * hybrj_(void(*) (int *,double*,double*,double *,int*, int*),
if ((info == 4 || info == 5 )&& retries < 3) { /* First try to decrease factor*/ \
retries++; giveUp = 0; \
factor = factor / 10.0; \
if (sim_verbose) \
if (sim_verbose & LOG_NONLIN_SYS) \
printf("Solving nonlinear system: iteration not making progress, trying to decrease factor to %f\n",factor); \
} else if ((info == 4 || info == 5) && retries < 5) { /* Secondly, try with different starting point*/ \
int i; \
for (i=0; i < n; i++) { nls_x[i]+=0.1; }; \
retries++; giveUp=0; \
if (sim_verbose) \
if (sim_verbose & LOG_NONLIN_SYS) \
printf("Solving nonlinear system: iteration not making progress, trying with different starting points (+1e-6)"); \
} \
else if (info >= 2 && info <= 5) { \
Expand Down Expand Up @@ -133,7 +133,7 @@ void * hybrj_(void(*) (int *,double*,double*,double *,int*, int*),
for (i=0; i < n; i++) { nls_x[i]+=0.1; }; \
retries++; giveUp=0; \
if (sim_verbose) \
printf("Solving nonlinear system: iteration not making progress, trying with different starting points (+1e-6)"); \
printf("Solving nonlinear system: iteration not making progress, trying with different starting points (+1e-6)\n"); \
} \
else if (info >= 2 && info <= 5) { \
printf("error solving nonlinear system nr. %d at time %f\n",no,time); \
Expand Down
5 changes: 4 additions & 1 deletion c_runtime/simulation_runtime.cpp
Expand Up @@ -71,7 +71,10 @@ long* zeroCrossingEnabled;
// this is the globalData that is used in all the functions
DATA *globalData = 0;


/* Flags for controlling logging to stdout */
const int LOG_EVENTS = 1;
const int LOG_NONLIN_SYS = 2;
const int LOG_DEBUG = 4;

#define MAXORD 5

Expand Down
6 changes: 6 additions & 0 deletions c_runtime/simulation_runtime.h
Expand Up @@ -140,6 +140,12 @@ double old2(double*);

extern int sim_verbose; // control debug output during simulation.

/* Flags for controlling logging to stdout */
extern const int LOG_EVENTS;
extern const int LOG_NONLIN_SYS;
extern const int LOG_DEBUG;


/* extern double* h; */
/* extern double* x; */
/* extern double* xd; */
Expand Down

0 comments on commit ddb2c96

Please sign in to comment.