Skip to content

Commit 712376b

Browse files
committed
remove redundant code in write_cube
1 parent 32228d7 commit 712376b

File tree

16 files changed

+11
-306
lines changed

16 files changed

+11
-306
lines changed

source/module_esolver/esolver_fp.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,6 @@ void ESolver_FP::after_scf(const int istep)
156156
}
157157
std::string fn =PARAM.globalv.global_out_dir + "/SPIN" + std::to_string(is + 1) + "_CHG.cube";
158158
ModuleIO::write_cube(
159-
#ifdef __MPI
160-
this->pw_big->bz,
161-
this->pw_big->nbz,
162-
this->pw_rhod->nplane,
163-
this->pw_rhod->startz_current,
164-
#endif
165159
data,
166160
is,
167161
PARAM.inp.nspin,
@@ -178,12 +172,6 @@ void ESolver_FP::after_scf(const int istep)
178172
{
179173
fn =PARAM.globalv.global_out_dir + "/SPIN" + std::to_string(is + 1) + "_TAU.cube";
180174
ModuleIO::write_cube(
181-
#ifdef __MPI
182-
this->pw_big->bz,
183-
this->pw_big->nbz,
184-
this->pw_rhod->nplane,
185-
this->pw_rhod->startz_current,
186-
#endif
187175
this->pelec->charge->kin_r_save[is],
188176
is,
189177
PARAM.inp.nspin,
@@ -224,12 +212,6 @@ void ESolver_FP::after_scf(const int istep)
224212
std::string fn =PARAM.globalv.global_out_dir + "/SPIN" + std::to_string(is + 1) + "_POT.cube";
225213

226214
ModuleIO::write_cube(
227-
#ifdef __MPI
228-
this->pw_big->bz,
229-
this->pw_big->nbz,
230-
this->pw_rhod->nplane,
231-
this->pw_rhod->startz_current,
232-
#endif
233215
this->pelec->pot->get_effective_v(is),
234216
is,
235217
PARAM.inp.nspin,

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,12 +1030,6 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(int& iter)
10301030
}
10311031
std::string fn = PARAM.globalv.global_out_dir + "/tmp_SPIN" + std::to_string(is + 1) + "_CHG.cube";
10321032
ModuleIO::write_cube(
1033-
#ifdef __MPI
1034-
this->pw_big->bz,
1035-
this->pw_big->nbz,
1036-
this->pw_rhod->nplane,
1037-
this->pw_rhod->startz_current,
1038-
#endif
10391033
data,
10401034
is,
10411035
PARAM.inp.nspin,
@@ -1052,12 +1046,6 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(int& iter)
10521046
{
10531047
fn = PARAM.globalv.global_out_dir + "/tmp_SPIN" + std::to_string(is + 1) + "_TAU.cube";
10541048
ModuleIO::write_cube(
1055-
#ifdef __MPI
1056-
this->pw_big->bz,
1057-
this->pw_big->nbz,
1058-
this->pw_rhod->nplane,
1059-
this->pw_rhod->startz_current,
1060-
#endif
10611049
this->pelec->charge->kin_r_save[is],
10621050
is,
10631051
PARAM.inp.nspin,

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,6 @@ void ESolver_KS_PW<T, Device>::before_scf(const int istep)
240240
std::stringstream ss;
241241
ss << PARAM.globalv.global_out_dir << "SPIN" << is + 1 << "_CHG_INI.cube";
242242
ModuleIO::write_cube(
243-
#ifdef __MPI
244-
this->pw_big->bz,
245-
this->pw_big->nbz,
246-
this->pw_rhod->nplane,
247-
this->pw_rhod->startz_current,
248-
#endif
249243
this->pelec->charge->rho[is],
250244
is,
251245
PARAM.inp.nspin,
@@ -267,12 +261,6 @@ void ESolver_KS_PW<T, Device>::before_scf(const int istep)
267261
std::stringstream ss;
268262
ss << PARAM.globalv.global_out_dir << "SPIN" << is + 1 << "_POT_INI.cube";
269263
ModuleIO::write_cube(
270-
#ifdef __MPI
271-
this->pw_big->bz,
272-
this->pw_big->nbz,
273-
this->pw_rhod->nplane,
274-
this->pw_rhod->startz_current,
275-
#endif
276264
this->pelec->pot->get_effective_v(is),
277265
is,
278266
PARAM.inp.nspin,
@@ -481,12 +469,6 @@ void ESolver_KS_PW<T, Device>::iter_finish(int& iter)
481469
}
482470
std::string fn = PARAM.globalv.global_out_dir + "/tmp_SPIN" + std::to_string(is + 1) + "_CHG.cube";
483471
ModuleIO::write_cube(
484-
#ifdef __MPI
485-
this->pw_big->bz,
486-
this->pw_big->nbz,
487-
this->pw_rhod->nplane,
488-
this->pw_rhod->startz_current,
489-
#endif
490472
data,
491473
is,
492474
PARAM.inp.nspin,
@@ -503,12 +485,6 @@ void ESolver_KS_PW<T, Device>::iter_finish(int& iter)
503485
{
504486
fn = PARAM.globalv.global_out_dir + "/tmp_SPIN" + std::to_string(is + 1) + "_TAU.cube";
505487
ModuleIO::write_cube(
506-
#ifdef __MPI
507-
this->pw_big->bz,
508-
this->pw_big->nbz,
509-
this->pw_rhod->nplane,
510-
this->pw_rhod->startz_current,
511-
#endif
512488
this->pelec->charge->kin_r_save[is],
513489
is,
514490
PARAM.inp.nspin,

source/module_esolver/lcao_before_scf.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,6 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(const int istep)
228228
std::stringstream ss;
229229
ss << PARAM.globalv.global_out_dir << "SPIN" << is + 1 << "_CHG_INI.cube";
230230
ModuleIO::write_cube(
231-
#ifdef __MPI
232-
this->pw_big->bz, // bz first, then nbz
233-
this->pw_big->nbz,
234-
this->pw_rhod->nplane,
235-
this->pw_rhod->startz_current,
236-
#endif
237231
this->pelec->charge->rho[is],
238232
is,
239233
PARAM.inp.nspin,
@@ -255,12 +249,6 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(const int istep)
255249
std::stringstream ss;
256250
ss << PARAM.globalv.global_out_dir << "SPIN" << is + 1 << "_POT_INI.cube";
257251
ModuleIO::write_cube(
258-
#ifdef __MPI
259-
this->pw_big->bz,
260-
this->pw_big->nbz,
261-
this->pw_rhod->nplane,
262-
this->pw_rhod->startz_current,
263-
#endif
264252
this->pelec->pot->get_effective_v(is),
265253
is,
266254
PARAM.inp.nspin,
@@ -310,12 +298,6 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(const int istep)
310298
{
311299
std::string fn = PARAM.globalv.global_out_dir + "/SPIN" + std::to_string(is + 1) + "_CHG.cube";
312300
ModuleIO::write_cube(
313-
#ifdef __MPI
314-
this->pw_big->bz,
315-
this->pw_big->nbz,
316-
this->pw_rhod->nplane,
317-
this->pw_rhod->startz_current,
318-
#endif
319301
this->pelec->charge->rho[is],
320302
is,
321303
PARAM.inp.nspin,

source/module_esolver/lcao_nscf.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,6 @@ void ESolver_KS_LCAO<TK, TR>::nscf() {
197197
std::string fn = PARAM.globalv.global_out_dir + "/SPIN" + std::to_string(is + 1) + "_POT.cube";
198198

199199
ModuleIO::write_cube(
200-
#ifdef __MPI
201-
this->pw_big->bz,
202-
this->pw_big->nbz,
203-
this->pw_rhod->nplane,
204-
this->pw_rhod->startz_current,
205-
#endif
206200
this->pelec->pot->get_effective_v(is),
207201
is,
208202
PARAM.inp.nspin,

source/module_esolver/pw_nscf.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,6 @@ void ESolver_KS_PW<T, Device>::nscf() {
166166
std::string fn = PARAM.globalv.global_out_dir + "/SPIN" + std::to_string(is + 1) + "_POT.cube";
167167

168168
ModuleIO::write_cube(
169-
#ifdef __MPI
170-
this->pw_big->bz,
171-
this->pw_big->nbz,
172-
this->pw_rhod->nplane,
173-
this->pw_rhod->startz_current,
174-
#endif
175169
this->pelec->pot->get_effective_v(is),
176170
is,
177171
PARAM.inp.nspin,

source/module_hamilt_pw/hamilt_pwdft/parallel_grid.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ void Parallel_Grid::zpiece_to_stogroup(double *zpiece, const int &iz, double *rh
323323
return;
324324

325325
}
326-
void Parallel_Grid::reduce_to_fullrho(double *rhotot, double *rhoin)
326+
void Parallel_Grid::reduce_to_fullrho(double* rhotot, const double* const rhoin)
327327
{
328328
//ModuleBase::TITLE("Parallel_Grid","reduce_to_fullrho");
329329

@@ -374,13 +374,9 @@ void Parallel_Grid::reduce_to_fullrho(double *rhotot, double *rhoin)
374374

375375
if(GlobalV::MY_RANK==0)
376376
{
377-
for(int ix=0; ix<this->ncx; ix++)
378-
{
379-
for(int iy=0; iy<this->ncy; iy++)
380-
{
381-
const int ir = ix * this->ncy + iy;
382-
rhotot[ix * ncy * ncz + iy * ncz + iz] = zpiece[ir];
383-
}
377+
for (int ixy = 0; ixy < this->ncxy;++ixy)
378+
{
379+
rhotot[ixy * ncz + iz] = zpiece[ixy];
384380
}
385381
}
386382
}

source/module_hamilt_pw/hamilt_pwdft/parallel_grid.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Parallel_Grid
2424
void zpiece_to_all(double *zpiece, const int &iz, double *rho) const;
2525
void zpiece_to_stogroup(double *zpiece, const int &iz, double *rho) const; //qainrui add for sto-dft 2021-7-21
2626

27-
void reduce_to_fullrho(double *rhotot, double *rhoin);
27+
void reduce_to_fullrho(double* rhotot, const double* constrhoin);
2828
#endif
2929

3030
private:
@@ -41,7 +41,7 @@ class Parallel_Grid
4141
int ncz;
4242
int ncxy;
4343
int ncxyz;
44-
int nczp; // different processors have different values.
44+
int nczp; // number of z-layers (xy-planes) in each processor
4545
int nrxx;
4646
int nbz;
4747
int bz;

source/module_io/cube_io.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ bool read_cube(
2222
const int nat);
2323

2424
void write_cube(
25-
#ifdef __MPI
26-
const int bz,
27-
const int nbz,
28-
const int nplane,
29-
const int startz_current,
30-
#endif
3125
const double*const data,
3226
const int is,
3327
const int nspin,
@@ -75,13 +69,7 @@ void read_cube_core_mismatch(
7569
// when serial:
7670
// write data[iz*nxy+ixy] to file as order (ixy,iz)
7771
void write_cube_core(
78-
std::ofstream &ofs_cube,
79-
#ifdef __MPI
80-
const int bz,
81-
const int nbz,
82-
const int nplane,
83-
const int startz_current,
84-
#endif
72+
std::ofstream& ofs_cube,
8573
const double*const data,
8674
const int nxy,
8775
const int nz,

source/module_io/get_pchg_lcao.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ void IState_Charge::begin(Gint_Gamma& gg,
131131
// const double ef_tmp = pelec->eferm.get_efval(is);
132132
double ef_spin = ef_all_spin[is];
133133
ModuleIO::write_cube(
134-
#ifdef __MPI
135-
bigpw_bz,
136-
bigpw_nbz,
137-
rhopw_nplane,
138-
rhopw_startz_current,
139-
#endif
140134
rho_save[is].data(),
141135
is,
142136
nspin,
@@ -266,12 +260,6 @@ void IState_Charge::begin(Gint_k& gk,
266260

267261
double ef_spin = ef_all_spin[is];
268262
ModuleIO::write_cube(
269-
#ifdef __MPI
270-
bigpw_bz,
271-
bigpw_nbz,
272-
rhopw_nplane,
273-
rhopw_startz_current,
274-
#endif
275263
rho_save[is].data(),
276264
is,
277265
nspin,
@@ -334,12 +322,6 @@ void IState_Charge::begin(Gint_k& gk,
334322

335323
double ef_spin = ef_all_spin[is];
336324
ModuleIO::write_cube(
337-
#ifdef __MPI
338-
bigpw_bz,
339-
bigpw_nbz,
340-
rhopw_nplane,
341-
rhopw_startz_current,
342-
#endif
343325
rho_save[is].data(),
344326
is,
345327
nspin,

0 commit comments

Comments
 (0)