--- trunk/mdtools/md_code/Thermo.cpp 2002/12/29 18:13:23 217 +++ trunk/mdtools/md_code/Thermo.cpp 2002/12/29 19:11:05 218 @@ -1,4 +1,5 @@ #include +#include #include "Thermo.hpp" #include "SRI.hpp" @@ -17,12 +18,15 @@ double Thermo::getKinetic(){ DirectionalAtom *dAtom; int n_atoms; + double kinetic_global; Atom** atoms; + n_atoms = entry_plug->n_atoms; atoms = entry_plug->atoms; kinetic = 0.0; + kinetic_global = 0.0; for( kl=0; kl < n_atoms; kl++ ){ vx2 = atoms[kl]->get_vx() * atoms[kl]->get_vx(); @@ -44,7 +48,11 @@ double Thermo::getKinetic(){ + (jz2 / dAtom->getIzz()); } } - +#ifdef IS_MPI + MPI_COMM_WORLD.Allreduce(&kinetic,&kinetic_global,1,MPI_DOUBLE,MPI_SUM); + kinetic = kinetic_global; +#endif + kinetic = kinetic * 0.5 / e_convert; return kinetic; @@ -53,6 +61,7 @@ double Thermo::getPotential(){ double Thermo::getPotential(){ double potential; + double potential_global; int el, nSRI; SRI** sris; @@ -60,16 +69,21 @@ double Thermo::getPotential(){ nSRI = entry_plug->n_SRI; potential = 0.0; - + potential_global = 0.0; potential += entry_plug->longRange->get_potential();; // std::cerr << "long range potential: " << potential << "\n"; - for( el=0; elget_potential(); } + // Get total potential for entire system from MPI. +#ifdef IS_MPI + MPI_COMM_WORLD.Allreduce(&potential,&potential_global,1,MPI_DOUBLE,MPI_SUM); + potential = potential_global; +#endif + return potential; }