@@ -53,10 +53,17 @@ void ESolver_KS:: Run(const int istep, UnitCell_pseudo& cell)
5353 clock_t iterstart,iterend;
5454 iterstart = std::clock ();
5555 set_ethr (istep,iter);
56- eachiterinit (iter);
56+ eachiterinit (iter);
5757
5858 this ->hamilt2density (istep, iter, this ->diag_ethr );
5959
60+ // <Temporary> It may be changed when more clever parallel algorithm is put forward.
61+ // When parallel algorithm for bands are adopted. Density will only be treated in the first group.
62+ // (Different ranks should have abtained the same, but small differences always exist in practice.)
63+ // Maybe in the future, density and wavefunctions should use different parallel algorithms, in which
64+ // they do not occupy all processors, for example wavefunctions uses 20 processors while density uses 10.
65+ if (GlobalV::MY_STOGROUP == 0 )
66+ {
6067 // double drho = this->estate.caldr2();
6168 // EState should be used after it is constructed.
6269 drho = GlobalC::CHR.get_drho ();
@@ -88,6 +95,13 @@ void ESolver_KS:: Run(const int istep, UnitCell_pseudo& cell)
8895 // conv_elec = this->estate.mix_rho();
8996 GlobalC::CHR.mix_rho (iter);
9097 }
98+
99+ }
100+ #ifdef __MPI
101+ MPI_Bcast (&drho, 1 , MPI_DOUBLE , 0 , PARAPW_WORLD);
102+ MPI_Bcast (&conv_elec, 1 , MPI_DOUBLE , 0 , PARAPW_WORLD);
103+ MPI_Bcast (GlobalC::CHR.rho [0 ], GlobalC::pw.nrxx , MPI_DOUBLE, 0 , PARAPW_WORLD);
104+ #endif
91105
92106 // Hamilt should be used after it is constructed.
93107 // this->phamilt->update(conv_elec);
0 commit comments