Skip to content

Commit d672bca

Browse files
committed
move the after_all_runners() function of the base class to the end
1 parent 440b690 commit d672bca

File tree

7 files changed

+23
-11
lines changed

7 files changed

+23
-11
lines changed

source/source_esolver/esolver_gets.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,14 @@ void ESolver_GetS::runner(UnitCell& ucell, const int istep)
154154
ModuleBase::timer::tick("ESolver_GetS", "runner");
155155
}
156156

157-
void ESolver_GetS::after_all_runners(UnitCell& ucell) {};
157+
void ESolver_GetS::after_all_runners(UnitCell& ucell)
158+
{};
159+
158160
double ESolver_GetS::cal_energy()
159161
{
160162
return 0.0;
161163
};
164+
162165
void ESolver_GetS::cal_force(UnitCell& ucell, ModuleBase::matrix& force) {};
163166
void ESolver_GetS::cal_stress(UnitCell& ucell, ModuleBase::matrix& stress) {};
164167

source/source_esolver/esolver_ks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ void ESolver_KS<T, Device>::after_scf(UnitCell& ucell, const int istep, const bo
606606
template <typename T, typename Device>
607607
void ESolver_KS<T, Device>::after_all_runners(UnitCell& ucell)
608608
{
609-
// 1) write Etot information
609+
//! Ensure the function of base class is called last
610610
ESolver_FP::after_all_runners(ucell);
611611
}
612612

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
410410
ModuleBase::TITLE("ESolver_KS_LCAO", "after_all_runners");
411411
ModuleBase::timer::tick("ESolver_KS_LCAO", "after_all_runners");
412412

413-
ESolver_KS<TK>::after_all_runners(ucell);
414413

415414
const int nspin0 = (PARAM.inp.nspin == 2) ? 2 : 1;
416415

@@ -512,6 +511,9 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
512511
);
513512
}
514513

514+
//! Ensure the function of base class is called last
515+
ESolver_KS<TK>::after_all_runners(ucell);
516+
515517
ModuleBase::timer::tick("ESolver_KS_LCAO", "after_all_runners");
516518
}
517519

source/source_esolver/esolver_ks_lcaopw.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ namespace ModuleESolver
236236
template <typename T>
237237
void ESolver_KS_LIP<T>::after_all_runners(UnitCell& ucell)
238238
{
239-
ESolver_KS_PW<T>::after_all_runners(ucell);
240239

241240
#ifdef __LCAO
242241
if (PARAM.inp.out_mat_xc)
@@ -262,6 +261,10 @@ namespace ModuleESolver
262261
);
263262
}
264263
#endif
264+
265+
//! Ensure the function of base class is called last
266+
ESolver_KS_PW<T>::after_all_runners(ucell);
267+
265268
}
266269
template class ESolver_KS_LIP<std::complex<float>>;
267270
template class ESolver_KS_LIP<std::complex<double>>;

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,16 @@ void ESolver_KS_PW<T, Device>::cal_stress(UnitCell& ucell, ModuleBase::matrix& s
530530
template <typename T, typename Device>
531531
void ESolver_KS_PW<T, Device>::after_all_runners(UnitCell& ucell)
532532
{
533-
ESolver_KS<T, Device>::after_all_runners(ucell);
534533

535534
ModuleIO::ctrl_runner_pw<T, Device>(ucell, this->pelec, this->pw_wfc,
536535
this->pw_rho, this->pw_rhod, this->chr, this->kv, this->psi,
537536
this->kspw_psi, this->__kspw_psi, this->sf,
538537
this->ppcell, this->solvent, this->ctx, this->Pgrid, PARAM.inp);
539538

540539
elecstate::teardown_estate_pw<T, Device>(this->pelec, this->vsep_cell);
540+
541+
//! Ensure the function of base class is called last
542+
ESolver_KS<T, Device>::after_all_runners(ucell);
541543

542544
}
543545

source/source_esolver/esolver_of.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ void ESolver_OF::after_opt(const int istep, UnitCell& ucell, const bool conv_eso
540540
*/
541541
void ESolver_OF::after_all_runners(UnitCell& ucell)
542542
{
543+
//! Ensure the function of base class is called last
543544
ESolver_FP::after_all_runners(ucell);
544545
}
545546

source/source_esolver/esolver_sdft_pw.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,13 @@ void ESolver_SDFT_PW<T, Device>::cal_stress(UnitCell& ucell, ModuleBase::matrix&
259259
template <typename T, typename Device>
260260
void ESolver_SDFT_PW<T, Device>::after_all_runners(UnitCell& ucell)
261261
{
262-
// 1) write down etot and eigenvalues (for MDFT) information
263-
ESolver_FP::after_all_runners(ucell);
264-
265-
// 2) release memory
262+
// release memory
266263
if (this->method_sto == 2)
267264
{
268265
stowf.clean_chiallorder(); // release lots of memories
269266
}
270267

271-
// 3) write down DOS
268+
// write down DOS
272269
if (PARAM.inp.out_dos)
273270
{
274271
if(!std::is_same<T, std::complex<double>>::value || !std::is_same<Device, base_device::DEVICE_CPU>::value)
@@ -294,7 +291,7 @@ void ESolver_SDFT_PW<T, Device>::after_all_runners(UnitCell& ucell)
294291
sto_dos.caldos(PARAM.inp.dos_sigma, PARAM.inp.dos_edelta_ev, PARAM.inp.npart_sto);
295292
}
296293

297-
// 4) sKG cost memory, and it should be placed at the end of the program
294+
// sKG cost memory, and it should be placed near the end of the program
298295
if (PARAM.inp.cal_cond)
299296
{
300297
Sto_EleCond<Real, Device> sto_elecond(&ucell,
@@ -315,6 +312,10 @@ void ESolver_SDFT_PW<T, Device>::after_all_runners(UnitCell& ucell)
315312
PARAM.inp.cond_nonlocal,
316313
PARAM.inp.npart_sto);
317314
}
315+
316+
// write down etot and eigenvalues (for MDFT) information
317+
ESolver_FP::after_all_runners(ucell);
318+
318319
}
319320

320321

0 commit comments

Comments
 (0)