@@ -113,19 +113,25 @@ void PW_Basis_Sup::distribution_method3(const ModulePW::PW_Basis* pw_rho)
113113 // calculate this->nstot and this->npwtot, liy, riy
114114 this ->count_pw_st (st_length2D, st_bottom2D);
115115 }
116+ if (mpi_flag_)
117+ {
116118#ifdef __MPI
117- MPI_Bcast (&this ->npwtot , 1 , MPI_INT, 0 , this ->pool_world );
118- MPI_Bcast (&this ->nstot , 1 , MPI_INT, 0 , this ->pool_world );
119- MPI_Bcast (&liy, 1 , MPI_INT, 0 , this ->pool_world );
120- MPI_Bcast (&riy, 1 , MPI_INT, 0 , this ->pool_world );
121- MPI_Bcast (&lix, 1 , MPI_INT, 0 , this ->pool_world );
122- MPI_Bcast (&rix, 1 , MPI_INT, 0 , this ->pool_world );
119+
120+ MPI_Bcast (&this ->npwtot , 1 , MPI_INT, 0 , this ->pool_world );
121+ MPI_Bcast (&this ->nstot , 1 , MPI_INT, 0 , this ->pool_world );
122+ MPI_Bcast (&liy, 1 , MPI_INT, 0 , this ->pool_world );
123+ MPI_Bcast (&riy, 1 , MPI_INT, 0 , this ->pool_world );
124+ MPI_Bcast (&lix, 1 , MPI_INT, 0 , this ->pool_world );
125+ MPI_Bcast (&rix, 1 , MPI_INT, 0 , this ->pool_world );
123126#endif
127+ }
124128 delete[] this ->istot2ixy ;
125129 this ->istot2ixy = new int [this ->nstot ];
126130
127131 if (poolrank == 0 )
128132 {
133+ if (mpi_flag_)
134+ {
129135#ifdef __MPI
130136 // Parallel line
131137 // (2) Collect the x, y indexs, and length of the sticks.
@@ -147,7 +153,8 @@ void PW_Basis_Sup::distribution_method3(const ModulePW::PW_Basis* pw_rho)
147153 // We do not need startnsz_per after it.
148154 delete[] this ->startnsz_per ;
149155 this ->startnsz_per = nullptr ;
150- #else
156+ #endif
157+ }else {
151158 // Serial line
152159 // get nst_per, npw_per, fftixy2ip, and istot2ixy
153160 this ->nst_per [0 ] = this ->nstot ;
@@ -162,17 +169,20 @@ void PW_Basis_Sup::distribution_method3(const ModulePW::PW_Basis* pw_rho)
162169 st_move++;
163170 }
164171 }
165- #endif
166172 }
167-
173+ }
174+ if (mpi_flag_)
175+ {
168176#ifdef __MPI
169- MPI_Bcast (st_length2D, this ->fftnxy , MPI_INT, 0 , this ->pool_world );
170- MPI_Bcast (st_bottom2D, this ->fftnxy , MPI_INT, 0 , this ->pool_world );
171- MPI_Bcast (this ->fftixy2ip , this ->fftnxy , MPI_INT, 0 , this ->pool_world );
172- MPI_Bcast (this ->istot2ixy , this ->nstot , MPI_INT, 0 , this ->pool_world );
173- MPI_Bcast (this ->nst_per , this ->poolnproc , MPI_INT, 0 , this ->pool_world );
174- MPI_Bcast (this ->npw_per , this ->poolnproc , MPI_INT, 0 , this ->pool_world );
177+
178+ MPI_Bcast (st_length2D, this ->fftnxy , MPI_INT, 0 , this ->pool_world );
179+ MPI_Bcast (st_bottom2D, this ->fftnxy , MPI_INT, 0 , this ->pool_world );
180+ MPI_Bcast (this ->fftixy2ip , this ->fftnxy , MPI_INT, 0 , this ->pool_world );
181+ MPI_Bcast (this ->istot2ixy , this ->nstot , MPI_INT, 0 , this ->pool_world );
182+ MPI_Bcast (this ->nst_per , this ->poolnproc , MPI_INT, 0 , this ->pool_world );
183+ MPI_Bcast (this ->npw_per , this ->poolnproc , MPI_INT, 0 , this ->pool_world );
175184#endif
185+ }
176186 this ->npw = this ->npw_per [this ->poolrank ];
177187 this ->nst = this ->nst_per [this ->poolrank ];
178188 this ->nstnz = this ->nst * this ->nz ;
0 commit comments