Skip to content

Commit

Permalink
added debuge dump for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
vruge authored and OpenModelica-Hudson committed Feb 28, 2016
1 parent ca1480a commit 5d5c631
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -6548,7 +6548,9 @@ algorithm
if Flags.isSet(Flags.DUMP_EQNINORDER) then
BackendDump.dumpEqnsSolved(outSimDAE, "indxdae: eqns in order");
end if;

if Flags.isSet(Flags.DUMP_LOOPS) then
BackendDump.dumpLoops(outSimDAE);
end if;
checkBackendDAEWithErrorMsg(outSimDAE);
end getSolvedSystem;

Expand Down
33 changes: 31 additions & 2 deletions Compiler/BackEnd/BackendDump.mo
Expand Up @@ -1063,13 +1063,15 @@ algorithm
vlst1 = List.flatten(List.map(eqnsvartpllst,Util.tuple22));
elst1 = List.map(eqnsvartpllst,Util.tuple21);
varlst = List.map1r(vlst1, BackendVariable.getVarAt, vars);
print("\ninternal vars\n");
printVarList(varlst);
varlst = List.map1r(vlst, BackendVariable.getVarAt, vars);
print("\nresidual vars\n");
printVarList(varlst);
print("\n");
print("\ninternal equation\n");
eqnlst = BackendEquation.getEqns(elst1,eqns);
printEquationList(eqnlst);
print("\n");
print("\nresidual equations\n");
eqnlst = BackendEquation.getEqns(elst,eqns);
printEquationList(eqnlst);
print("\n");
Expand Down Expand Up @@ -1126,6 +1128,33 @@ algorithm
end matchcontinue;
end dumpEqnsSolved2;

public function dumpLoops "author: vitalij"
input BackendDAE.BackendDAE inDAE;
output BackendDAE.BackendDAE outDAE = inDAE;
protected
BackendDAE.StrongComponents comps;
BackendDAE.EquationArray eqns;
BackendDAE.Variables vars;
Integer isyst = 1;
algorithm
_ := match outDAE.shared
case BackendDAE.SHARED(backendDAEType=BackendDAE.SIMULATION()) then print("SIMULATION\n");
case BackendDAE.SHARED(backendDAEType=BackendDAE.INITIALSYSTEM()) then print("INITIALSYSTEM\n");
else print("UNKNOWN\n");
end match;

for syst in inDAE.eqs loop
print("\nsystem " + intString(isyst) + "\n");
BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns, matching=BackendDAE.MATCHING(comps=comps)) := syst;
for comp in comps loop
if BackendEquation.isEquationsSystem(comp) or BackendEquation.isTornSystem(comp) then
dumpEqnsSolved2({comp}, eqns, vars);
end if;
end for;
isyst := isyst + 1;
end for;
end dumpLoops;

public function dumpComponentsAdvanced "author: Frenkel TUD
Prints the blocks of the BLT sorting on stdout."
input list<list<Integer>> l;
Expand Down
6 changes: 5 additions & 1 deletion Compiler/Util/Flags.mo
Expand Up @@ -480,6 +480,9 @@ constant DebugFlag DISABLE_JACSCC = DEBUG_FLAG(155, "disableJacsforSCC", false,
Util.gettext("Disables calculation of jacobians to detect if a SCC is linear or non-linear. By disabling all SCC will handled like non-linear."));
constant DebugFlag FORCE_NLS_ANALYTIC_JACOBIAN = DEBUG_FLAG(156, "forceNLSanalyticJacobian", false,
Util.gettext("Forces calculation analytical jacobian also for non-linear strong components with user-defined functions."));
constant DebugFlag DUMP_LOOPS = DEBUG_FLAG(157, "dumpLoops", false,
Util.gettext("Dumps loop equation."));


// This is a list of all debug flags, to keep track of which flags are used. A
// flag can not be used unless it's in this list, and the list is checked at
Expand Down Expand Up @@ -642,7 +645,8 @@ constant list<DebugFlag> allDebugFlags = {
DUMP_EXCLUDED_EXP,
DEBUG_ALGLOOP_JACOBIAN,
DISABLE_JACSCC,
FORCE_NLS_ANALYTIC_JACOBIAN
FORCE_NLS_ANALYTIC_JACOBIAN,
DUMP_LOOPS
};

public
Expand Down

0 comments on commit 5d5c631

Please sign in to comment.