Skip to content

Commit

Permalink
Throw an error if the user attempts to take a derivative of a temporary.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenrbrandt committed Mar 5, 2015
1 parent 41311ee commit ba27df2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Tools/CodeGen/CodeGenCalculation.m
Expand Up @@ -547,6 +547,14 @@ General Utility Functions (could be moved outside this package)

Options[equationLoop] = ThornOptions;

HasBadDeriv[eqn_,shorts_] :=
eqn /. Global`PDstandard[arg_,_,_] :>
If[ MemberQ[shorts,arg],
ThrowError[
"The cacluation "<>ToString[eqn]<>
" contains the derivative of a temporary (" <>
ToString[arg] <> "). This isn't allowed."]];

DefFn[
equationLoop[eqs_, cleancalc_, gfs_, shorts_, incs_, groups_, odeGroups_, pddefs_,
where_, addToStencilWidth_,
Expand All @@ -560,6 +568,7 @@ General Utility Functions (could be moved outside this package)
gridName, useJacobian, allCode, opCounts},

InfoMessage[InfoFull, "Equation loop"];
Do[HasBadDeriv[eqn,shorts],{eqn,eqs}];

{allCode, opCounts} = Reap[

Expand Down

0 comments on commit ba27df2

Please sign in to comment.