From 9130641820c5bba2306f89e87d8c01083757e23d Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 2 May 2014 14:47:47 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11878 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/variable.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/variable.cpp b/src/variable.cpp index b9c5152d1e..3fdfde7eba 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -647,11 +647,12 @@ char *Variable::retrieve(char *name) double Variable::compute_equal(int ivar) { - // eval_in_progress used to detect circle dependencies - // could extend this later to check v_a = c_b + v_a constructs? - + if (eval_in_progress[ivar]) + error->all(FLERR,"Variable has circular dependency"); eval_in_progress[ivar] = 1; + double value = evaluate(data[ivar][0],NULL); + eval_in_progress[ivar] = 0; return value; } @@ -679,6 +680,10 @@ void Variable::compute_atom(int ivar, int igroup, Tree *tree; double *vstore; + if (eval_in_progress[ivar]) + error->all(FLERR,"Variable has circular dependency"); + eval_in_progress[ivar] = 1; + if (style[ivar] == ATOM) { evaluate(data[ivar][0],&tree); collapse_tree(tree); @@ -724,6 +729,8 @@ void Variable::compute_atom(int ivar, int igroup, } if (style[ivar] == ATOM) free_tree(tree); + + eval_in_progress[ivar] = 0; } /* ----------------------------------------------------------------------