Skip to content

Commit 5130f4b

Browse files
committed
fix bugs
1 parent d521c44 commit 5130f4b

File tree

3 files changed

+38
-27
lines changed

3 files changed

+38
-27
lines changed

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "source_io/ctrl_scf_lcao.h" // use ctrl_scf_lcao()
2323
#include "source_psi/setup_psi.h" // mohan add 20251019
2424
#include "source_io/read_wfc_nao.h"
25+
#include "source_io/print_info.h"
2526

2627
namespace ModuleESolver
2728
{
@@ -130,25 +131,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
130131
}
131132

132133
// 15) if kpar is not divisible by nks, print a warning
133-
if (PARAM.globalv.kpar_lcao > 1)
134-
{
135-
if (this->kv.get_nks() % PARAM.globalv.kpar_lcao != 0)
136-
{
137-
ModuleBase::WARNING("ESolver_KS_LCAO::before_all_runners", "nks is not divisible by kpar.");
138-
std::cout << "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
139-
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
140-
"%%%%%%%%%%%%%%%%%%%%%%%%%%"
141-
<< std::endl;
142-
std::cout << " Warning: nks (" << this->kv.get_nks() << ") is not divisible by kpar ("
143-
<< PARAM.globalv.kpar_lcao << ")." << std::endl;
144-
std::cout << " This may lead to poor load balance. It is strongly suggested to" << std::endl;
145-
std::cout << " set nks to be divisible by kpar, but if this is really what" << std::endl;
146-
std::cout << " you want, please ignore this warning." << std::endl;
147-
std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
148-
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
149-
"%%%%%%%%%%%%\n";
150-
}
151-
}
134+
ModuleIO::print_kpar(this->kv.get_nks(), PARAM.globalv.kpar_lcao);
152135

153136
// 16) init rdmft, added by jghan
154137
if (inp.rdmft == true)
@@ -667,7 +650,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep, const
667650
//! 3) Clean up RA, which is used to serach for adjacent atoms
668651
if (!PARAM.inp.cal_force && !PARAM.inp.cal_stress)
669652
{
670-
RA.delete_grid();
653+
this->RA.delete_grid();
671654
}
672655

673656
ModuleBase::timer::tick("ESolver_KS_LCAO", "after_scf");

source/source_io/print_info.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,4 +387,32 @@ void print_screen(const int& stress_step, const int& force_step, const int& iste
387387
GlobalV::ofs_running << " ================================================================" << std::endl;
388388
}
389389

390+
391+
void print_kpar(const int &nks, const int &kpar_lcao)
392+
{
393+
assert(nks>0);
394+
assert(kpar_lcao>0);
395+
396+
// 15) if kpar is not divisible by nks, print a warning
397+
if (kpar_lcao > 1)
398+
{
399+
if (nks % kpar_lcao != 0)
400+
{
401+
ModuleBase::WARNING("ModuleIO::print_kpar", "nks is not divisible by kpar.");
402+
std::cout << "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
403+
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
404+
"%%%%%%%%%%%%%%%%%%%%%%%%%%"
405+
<< std::endl;
406+
std::cout << " Warning: nks (" << nks << ") is not divisible by kpar ("
407+
<< kpar_lcao << ")." << std::endl;
408+
std::cout << " This may lead to poor load balance. It is strongly suggested to" << std::endl;
409+
std::cout << " set nks to be divisible by kpar, but if this is really what" << std::endl;
410+
std::cout << " you want, please ignore this warning." << std::endl;
411+
std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
412+
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
413+
"%%%%%%%%%%%%\n";
414+
}
415+
}
416+
}
417+
390418
} // namespace ModuleIO

source/source_io/print_info.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
//==========================================================
2-
// AUTHOR : mohan
3-
// DATE : 2021-01-30
4-
//==========================================================
5-
#ifndef PRINT_INFO
6-
#define PRINT_INFO
1+
#ifndef PRINT_INFO_H
2+
#define PRINT_INFO_H
73

84
#include "source_base/timer.h"
95
#include "source_basis/module_pw/pw_basis_k.h"
@@ -13,22 +9,26 @@
139

1410
namespace ModuleIO
1511
{
16-
1712
// print out to screen about the readin parameters
1813
void print_parameters(
1914
const UnitCell& ucell,
2015
K_Vectors& kv,
2116
const Input_para& inp);
2217

2318
void print_time(time_t& time_start, time_t& time_finish);
19+
2420
void print_screen(const int& stress_step, const int& force_step, const int& istep);
21+
2522
//! Print charge density using FFT
2623
void print_rhofft(ModulePW::PW_Basis* pw_rhod,
2724
ModulePW::PW_Basis* pw_rho,
2825
ModulePW::PW_Basis_Big* pw_big,
2926
std::ofstream& ofs);
27+
3028
void print_wfcfft(const Input_para& inp, ModulePW::PW_Basis_K& pw_wfc, std::ofstream& ofs);
3129

30+
void print_kpar(const int &nks, const int &kpar_lcao);
31+
3232
} // namespace ModuleIO
3333

3434
#endif

0 commit comments

Comments
 (0)