Skip to content

Commit 919c560

Browse files
author
abacus_fixer
committed
refactor(klist): pass ofs_warning into generate_kfile
Remove the GlobalV::ofs_warning dependency from K_Vectors::generate_kfile by taking the stream as a parameter; the single caller (read_kpoints) passes GlobalV::ofs_warning. Private signature only, no public interface change. global_dependency count in klist.cpp drops by 2. Verified: cmake --build build_max_para_test -j30 (exit 0) and ctest -R "MODULE_CELL_(klist|reciprocal_grid|qlist)" -> 5/5.
1 parent bee21a3 commit 919c560

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

source/source_cell/klist.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ bool K_Vectors::read_kpoints(const UnitCell& ucell,
225225

226226
// 1. Overwrite the KPT file and default K-point information if needed
227227
// mohan add 2010-09-04
228-
this->generate_kfile(ucell, fn, gamma_only_local, kspacing, kmesh_type, koffset);
228+
this->generate_kfile(ucell, fn, gamma_only_local, kspacing, kmesh_type, koffset, GlobalV::ofs_warning);
229229

230230
// 2. Read the KPT file and build the k-point list
231231
return this->parse_kfile(fn, ofs_running);
@@ -236,11 +236,12 @@ void K_Vectors::generate_kfile(const UnitCell& ucell,
236236
const bool gamma_only_local,
237237
const double kspacing[3],
238238
const std::string& kmesh_type,
239-
const double koffset[3])
239+
const double koffset[3],
240+
std::ofstream& ofs_warning)
240241
{
241242
if (gamma_only_local)
242243
{
243-
GlobalV::ofs_warning << " Auto generating k-points file: " << fn << std::endl;
244+
ofs_warning << " Auto generating k-points file: " << fn << std::endl;
244245
std::ofstream ofs(fn.c_str());
245246
ofs << "K_POINTS" << std::endl;
246247
ofs << "0" << std::endl;
@@ -263,7 +264,7 @@ void K_Vectors::generate_kfile(const UnitCell& ucell,
263264
int nk2 = std::max(1, static_cast<int>(b2 * ModuleBase::TWO_PI / kspacing[1] / ucell.lat0 + 1));
264265
int nk3 = std::max(1, static_cast<int>(b3 * ModuleBase::TWO_PI / kspacing[2] / ucell.lat0 + 1));
265266

266-
GlobalV::ofs_warning << " Generate k-points file according to KSPACING: " << fn << std::endl;
267+
ofs_warning << " Generate k-points file according to KSPACING: " << fn << std::endl;
267268
std::ofstream ofs(fn.c_str());
268269
ofs << "K_POINTS" << std::endl;
269270
ofs << "0" << std::endl;

source/source_cell/klist.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ class K_Vectors : public ModuleCell::ReciprocalGrid
256256
const bool gamma_only_local,
257257
const double kspacing[3],
258258
const std::string& kmesh_type,
259-
const double koffset[3]);
259+
const double koffset[3],
260+
std::ofstream& ofs_warning);
260261

261262
/**
262263
* @brief Read the KPT file and build the k-point list from it.

0 commit comments

Comments
 (0)