diff --git a/src/fix_restrain.cpp b/src/fix_restrain.cpp index 80775e0283..4c0d3e4a29 100644 --- a/src/fix_restrain.cpp +++ b/src/fix_restrain.cpp @@ -652,8 +652,16 @@ double FixRestrain::compute_scalar() double FixRestrain::compute_vector(int n) { - if (n == 0) return ebond; - if (n == 1) return eangle; - if (n == 2) return edihed; - return 0.0; + if (n == 0) { + MPI_Allreduce(&ebond,&ebond_all,1,MPI_DOUBLE,MPI_SUM,world); + return ebond_all; + } else if (n == 1) { + MPI_Allreduce(&eangle,&eangle_all,1,MPI_DOUBLE,MPI_SUM,world); + return eangle_all; + } else if (n == 2) { + MPI_Allreduce(&edihed,&edihed_all,1,MPI_DOUBLE,MPI_SUM,world); + return edihed_all; + } else { + return 0.0; + } } diff --git a/src/fix_restrain.h b/src/fix_restrain.h index c956e40982..4572905d46 100644 --- a/src/fix_restrain.h +++ b/src/fix_restrain.h @@ -47,7 +47,9 @@ class FixRestrain : public Fix { double *kstart,*kstop,*target; double *cos_target,*sin_target; double energy,energy_all; - double ebond,eangle,edihed; + double ebond,ebond_all; + double eangle,eangle_all; + double edihed,edihed_all; void restrain_bond(int); void restrain_angle(int);