@@ -100,8 +100,9 @@ void PW_Basis_Sup::distribution_method3(const ModulePW::PW_Basis* pw_rho)
100100 this ->npw_per = new int [this ->poolnproc ]; // number of planewaves on each core.
101101 delete[] this ->fftixy2ip ;
102102 this ->fftixy2ip = new int [this ->fftnxy ]; // ip of core which contains the stick on (x, y).
103- for (int ixy = 0 ; ixy < this ->fftnxy ; ++ixy)
103+ for (int ixy = 0 ; ixy < this ->fftnxy ; ++ixy) {
104104 this ->fftixy2ip [ixy] = -1 ; // meaning this stick has not been distributed or there is no stick on (x, y).
105+ }
105106 if (poolrank == 0 )
106107 {
107108 // (1) Count the total number of planewaves (tot_npw) and sticks (this->nstot).
@@ -212,10 +213,11 @@ void PW_Basis_Sup::divide_sticks_3(
212213 int fftnx_s = nx_s;
213214 if (this ->gamma_only )
214215 {
215- if (this ->xprime )
216+ if (this ->xprime ) {
216217 fftnx_s = int (nx_s / 2 ) + 1 ;
217- else
218+ } else {
218219 fftny_s = int (ny_s / 2 ) + 1 ;
220+ }
219221 }
220222
221223 int fftnxy_s = fftnx_s * fftny_s;
@@ -225,15 +227,19 @@ void PW_Basis_Sup::divide_sticks_3(
225227 {
226228 int ix = ixy / fftny_s;
227229 int iy = ixy % fftny_s;
228- if (ix >= int (nx_s / 2 ) + 1 )
230+ if (ix >= int (nx_s / 2 ) + 1 ) {
229231 ix -= nx_s;
230- if (iy >= int (ny_s / 2 ) + 1 )
232+ }
233+ if (iy >= int (ny_s / 2 ) + 1 ) {
231234 iy -= ny_s;
235+ }
232236
233- if (ix < 0 )
237+ if (ix < 0 ) {
234238 ix += nx;
235- if (iy < 0 )
239+ }
240+ if (iy < 0 ) {
236241 iy += ny;
242+ }
237243 int index = ix * this ->fftny + iy;
238244 int ip = fftixy2ip_s[ixy];
239245 if (ip >= 0 )
@@ -349,8 +355,9 @@ void PW_Basis_Sup::get_ig2isz_is2fftixy(
349355 fftixy2is[ixy] = st_move;
350356 st_move++;
351357 }
352- if (st_move == this ->nst )
358+ if (st_move == this ->nst ) {
353359 break ;
360+ }
354361 }
355362
356363 // distribute planewaves in the same order as smooth grids first.
@@ -363,28 +370,35 @@ void PW_Basis_Sup::get_ig2isz_is2fftixy(
363370 int ixy = pw_rho->is2fftixy [is];
364371 int ix = ixy / pw_rho->fftny ;
365372 int iy = ixy % pw_rho->fftny ;
366- if (ix >= int (pw_rho->nx / 2 ) + 1 )
373+ if (ix >= int (pw_rho->nx / 2 ) + 1 ) {
367374 ix -= pw_rho->nx ;
368- if (iy >= int (pw_rho->ny / 2 ) + 1 )
375+ }
376+ if (iy >= int (pw_rho->ny / 2 ) + 1 ) {
369377 iy -= pw_rho->ny ;
370- if (iz >= int (pw_rho->nz / 2 ) + 1 )
378+ }
379+ if (iz >= int (pw_rho->nz / 2 ) + 1 ) {
371380 iz -= pw_rho->nz ;
381+ }
372382
373- if (ix < 0 )
383+ if (ix < 0 ) {
374384 ix += this ->nx ;
375- if (iy < 0 )
385+ }
386+ if (iy < 0 ) {
376387 iy += this ->ny ;
377- if (iz < 0 )
388+ }
389+ if (iz < 0 ) {
378390 iz += this ->nz ;
391+ }
379392 int ixy_now = ix * this ->fftny + iy;
380393 int index = ixy_now * this ->nz + iz;
381394 int is_now = fftixy2is[ixy_now];
382395 int isz_now = is_now * this ->nz + iz;
383396 this ->ig2isz [ig] = isz_now;
384397 pw_filled++;
385398 found[index] = true ;
386- if (xprime && ix == 0 )
399+ if (xprime && ix == 0 ) {
387400 ng_xeq0++;
401+ }
388402 }
389403 assert (pw_filled == pw_rho->npw );
390404
@@ -397,21 +411,24 @@ void PW_Basis_Sup::get_ig2isz_is2fftixy(
397411 for (int iz = zstart; iz < zstart + st_length2D[ixy]; ++iz)
398412 {
399413 int z = iz;
400- if (z < 0 )
414+ if (z < 0 ) {
401415 z += this ->nz ;
416+ }
402417 if (!found[ixy * this ->nz + z])
403418 {
404419 found[ixy * this ->nz + z] = true ;
405420 int is = fftixy2is[ixy];
406421 this ->ig2isz [pw_filled] = is * this ->nz + z;
407422 pw_filled++;
408- if (xprime && ixy / fftny == 0 )
423+ if (xprime && ixy / fftny == 0 ) {
409424 ng_xeq0++;
425+ }
410426 }
411427 }
412428 }
413- if (pw_filled == this ->npw )
429+ if (pw_filled == this ->npw ) {
414430 break ;
431+ }
415432 }
416433
417434 delete[] fftixy2is;
0 commit comments