diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index d226c0585d..9342cb1c80 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -350,7 +350,8 @@ double ComputeReduce::compute_scalar() MPI_Allreduce(&one,&scalar,1,MPI_DOUBLE,MPI_MAX,world); } else if (mode == AVE) { MPI_Allreduce(&one,&scalar,1,MPI_DOUBLE,MPI_SUM,world); - scalar /= count(0); + bigint n = count(0); + if (n) scalar /= n; } return scalar; @@ -419,7 +420,8 @@ void ComputeReduce::compute_vector() } else if (mode == AVE) { for (int m = 0; m < nvalues; m++) { MPI_Allreduce(&onevec[m],&vector[m],1,MPI_DOUBLE,MPI_SUM,world); - vector[m] /= count(m); + bigint n = count(m); + if (n) vector[m] /= n; } } } diff --git a/src/fix_store_state.cpp b/src/fix_store_state.cpp index 54c94ad050..7f49140d57 100644 --- a/src/fix_store_state.cpp +++ b/src/fix_store_state.cpp @@ -440,7 +440,7 @@ void FixStoreState::end_of_step() // evaluate atom-style variable } else if (which[m] == VARIABLE) - input->variable->compute_atom(n,igroup,&values[0][m],nvalues,1); + input->variable->compute_atom(n,igroup,&values[0][m],nvalues,0); } } diff --git a/src/variable.cpp b/src/variable.cpp index 22286ee5d2..d98897df69 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -210,6 +210,7 @@ void Variable::set(int narg, char **arg) if (nvar == maxvar) extend(); style[nvar] = UNIVERSE; num[nvar] = narg - 2; + pad[nvar] = 0; data[nvar] = new char*[num[nvar]]; copy(num[nvar],&arg[2],data[nvar]); } else if (strcmp(arg[1],"uloop") == 0) { @@ -500,7 +501,7 @@ void Variable::compute_atom(int ivar, int igroup, if (sumflag == 0) { int m = 0; for (int i = 0; i < nlocal; i++) { - if (mask[i] && groupbit) result[m] = eval_tree(tree,i); + if (mask[i] & groupbit) result[m] = eval_tree(tree,i); else result[m] = 0.0; m += stride; }