From e0392674a2145b1bdedf61ed8de6483f1f539f13 Mon Sep 17 00:00:00 2001 From: Critsium Date: Tue, 19 May 2026 16:31:49 +0800 Subject: [PATCH 1/5] Remove parameter.h --- source/source_basis/module_ao/ORB_read.cpp | 18 +++++++++++------- source/source_basis/module_ao/ORB_read.h | 13 +++++++++---- .../module_ao/test/ORB_read_test.cpp | 4 ++-- .../module_ao/test/ORB_unittest.cpp | 1 + .../test/LCAO_deepks_test_prep.cpp | 1 + 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/source/source_basis/module_ao/ORB_read.cpp b/source/source_basis/module_ao/ORB_read.cpp index 61c3a8139be..b08cb3ac01b 100644 --- a/source/source_basis/module_ao/ORB_read.cpp +++ b/source/source_basis/module_ao/ORB_read.cpp @@ -4,7 +4,6 @@ #include "source_base/parallel_common.h" #include "source_base/timer.h" #include "source_base/tool_check.h" -#include "source_io/module_parameter/parameter.h" #include #include @@ -58,6 +57,7 @@ void LCAO_Orbitals::init( const double& lcao_rmax_in, const bool& deepks_setorb, const int& out_mat_r, + const bool& out_element_info, const bool& force_flag, const int& my_rank ) @@ -86,7 +86,7 @@ void LCAO_Orbitals::init( #ifdef __MPI bcast_files(ntype, my_rank); #endif - Read_Orbitals(ofs_in, ntype, lmax, deepks_setorb, out_mat_r, force_flag, my_rank); + Read_Orbitals(ofs_in, ntype, lmax, deepks_setorb, out_mat_r, out_element_info, force_flag, my_rank); return; } @@ -156,6 +156,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in, const int& lmax_in, const bool& deepks_setorb, const int& out_mat_r, + const bool& out_element_info, const bool& force_flag, // mohan add 2021-05-07 const int& my_rank) // mohan add 2021-04-26 { @@ -247,7 +248,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in, this->Phi = new Numerical_Orbital[ntype]; for (int it = 0; it < ntype; it++) { - this->Read_PAO(ofs_in, it, force_flag, my_rank); + this->Read_PAO(ofs_in, it, out_element_info, force_flag, my_rank); // caoyu add 2021-05-24 to reconstruct atom_arrange::set_sr_NL this->rcutmax_Phi = std::max(this->rcutmax_Phi, this->Phi[it].getRcut()); } @@ -263,7 +264,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in, delete[] this->Alpha; this->Alpha = new Numerical_Orbital[1]; // not related to atom type -- remain to be discussed - this->Read_Descriptor(ofs_in, force_flag, my_rank); + this->Read_Descriptor(ofs_in, out_element_info, force_flag, my_rank); } ModuleBase::timer::end("LCAO_Orbitals", "Read_Orbitals"); @@ -279,6 +280,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in, //------------------------------------------------------- void LCAO_Orbitals::Read_PAO(std::ofstream& ofs_in, const int& it, + const bool& out_element_info, const bool& force_flag, // mohan add 2021-05-07 const int& my_rank) // mohan add 2021-04-26 { @@ -311,7 +313,7 @@ void LCAO_Orbitals::Read_PAO(std::ofstream& ofs_in, int lmaxt = 0; int nchimaxt = 0; - this->read_orb_file(ofs_in, in_ao, it, lmaxt, nchimaxt, this->Phi, force_flag, my_rank); + this->read_orb_file(ofs_in, in_ao, it, lmaxt, nchimaxt, this->Phi, out_element_info, force_flag, my_rank); // lmax and nchimax for all types this->lmax = std::max(this->lmax, lmaxt); @@ -323,6 +325,7 @@ void LCAO_Orbitals::Read_PAO(std::ofstream& ofs_in, // caoyu add 2021-3-16 void LCAO_Orbitals::Read_Descriptor(std::ofstream& ofs_in, + const bool& out_element_info, const bool& force_flag, // mohan add 2021-05-07 const int& my_rank) // read descriptor basis { @@ -355,7 +358,7 @@ void LCAO_Orbitals::Read_Descriptor(std::ofstream& ofs_in, this->lmax_d = 0; this->nchimax_d = 0; - this->read_orb_file(ofs_in, in_de, 0, this->lmax_d, this->nchimax_d, this->Alpha, force_flag, my_rank); + this->read_orb_file(ofs_in, in_de, 0, this->lmax_d, this->nchimax_d, this->Alpha, out_element_info, force_flag, my_rank); in_de.close(); @@ -368,6 +371,7 @@ void LCAO_Orbitals::read_orb_file(std::ofstream& ofs_in, // GlobalV::ofs_running int& lmax, int& nchimax, Numerical_Orbital* ao, + const bool& out_element_info, const bool& force_flag, const int& my_rank) { @@ -588,7 +592,7 @@ void LCAO_Orbitals::read_orb_file(std::ofstream& ofs_in, // GlobalV::ofs_running this->kmesh, this->dk, this->dr_uniform, - PARAM.inp.out_element_info, + out_element_info, true, force_flag); // delta k mesh in reciprocal space diff --git a/source/source_basis/module_ao/ORB_read.h b/source/source_basis/module_ao/ORB_read.h index 6ee794c080a..ed5978ae6ba 100644 --- a/source/source_basis/module_ao/ORB_read.h +++ b/source/source_basis/module_ao/ORB_read.h @@ -34,6 +34,7 @@ class LCAO_Orbitals const double& lcao_rmax_in, const bool& deepks_setorb, const int& out_mat_r, + const bool& out_element_info, const bool& force_flag, const int& my_rank ); @@ -44,12 +45,14 @@ class LCAO_Orbitals const int &lmax_in, const bool &deepks_setorb, // mohan add 2021-04-25 const int &out_mat_r, // mohan add 2021-04-26 + const bool &out_element_info, const bool &force_flag, // mohan add 2021-05-07 const int &my_rank); // mohan add 2021-04-26 void Read_PAO( std::ofstream &ofs_in, const int& it, + const bool &out_element_info, const bool &force_flag, // mohan add 2021-05-07 const int& my_rank); // mohan add 2021-04-26 @@ -57,6 +60,7 @@ class LCAO_Orbitals void Read_Descriptor( std::ofstream &ofs_in, + const bool &out_element_info, const bool &force_flag, // mohan add 2021-05-07 const int &my_rank); //caoyu add 2020-3-16 @@ -119,11 +123,12 @@ class LCAO_Orbitals void read_orb_file( std::ofstream &ofs_in, - std::ifstream &ifs, - const int &it, - int &lmax, - int &nchimax, + std::ifstream &ifs, + const int &it, + int &lmax, + int &nchimax, Numerical_Orbital* ao, + const bool &out_element_info, const bool &force_flag, // mohan add 2021-05-07 const int &my_rank); //caoyu add 2021-04-26 diff --git a/source/source_basis/module_ao/test/ORB_read_test.cpp b/source/source_basis/module_ao/test/ORB_read_test.cpp index 78f137a62bc..3fa713a51f5 100644 --- a/source/source_basis/module_ao/test/ORB_read_test.cpp +++ b/source/source_basis/module_ao/test/ORB_read_test.cpp @@ -98,8 +98,8 @@ void LcaoOrbitalsTest::lcao_read() { lcao_.dR = dR_; lcao_.Rmax = Rmax_; - lcao_.Read_Orbitals(ofs_log_, ntype_, lmax_, deepks_setorb_, out_mat_r_, - force_flag_, my_rank_); + lcao_.Read_Orbitals(ofs_log_, ntype_, lmax_, deepks_setorb_, out_mat_r_, + false /* out_element_info */, force_flag_, my_rank_); } diff --git a/source/source_basis/module_ao/test/ORB_unittest.cpp b/source/source_basis/module_ao/test/ORB_unittest.cpp index adec0796c31..b7c2ff918f7 100644 --- a/source/source_basis/module_ao/test/ORB_unittest.cpp +++ b/source/source_basis/module_ao/test/ORB_unittest.cpp @@ -83,6 +83,7 @@ void test_orb::set_orbs() lcao_rmax, 0, 0, + false, // out_element_info 1, // force 0); // myrank diff --git a/source/source_lcao/module_deepks/test/LCAO_deepks_test_prep.cpp b/source/source_lcao/module_deepks/test/LCAO_deepks_test_prep.cpp index 7ec2fa89d6e..4b6621d5dd5 100644 --- a/source/source_lcao/module_deepks/test/LCAO_deepks_test_prep.cpp +++ b/source/source_lcao/module_deepks/test/LCAO_deepks_test_prep.cpp @@ -194,6 +194,7 @@ void test_deepks::set_orbs() lcao_rmax, PARAM.sys.deepks_setorb, out_mat_r, + PARAM.inp.out_element_info, PARAM.input.cal_force, my_rank); From 25201a97120875f0696bb8f18970d34b99beaf39 Mon Sep 17 00:00:00 2001 From: Critsium Date: Tue, 19 May 2026 17:20:53 +0800 Subject: [PATCH 2/5] Continue remove parameter.h --- source/source_basis/module_nao/numerical_radial.cpp | 9 ++++++--- source/source_basis/module_nao/numerical_radial.h | 6 ++++-- source/source_basis/module_nao/radial_set.cpp | 8 ++++++-- source/source_basis/module_nao/radial_set.h | 4 +++- source/source_basis/module_nao/two_center_bundle.cpp | 8 +++++--- source/source_basis/module_nao/two_center_bundle.h | 4 +++- source/source_lcao/LCAO_init_basis.cpp | 3 ++- source/source_lcao/module_lr/esolver_lrtd_lcao.cpp | 3 ++- source/source_lcao/module_lr/lr_spectrum_velocity.cpp | 3 ++- 9 files changed, 33 insertions(+), 15 deletions(-) diff --git a/source/source_basis/module_nao/numerical_radial.cpp b/source/source_basis/module_nao/numerical_radial.cpp index dec99ed56f8..beb3355a771 100644 --- a/source/source_basis/module_nao/numerical_radial.cpp +++ b/source/source_basis/module_nao/numerical_radial.cpp @@ -11,7 +11,6 @@ #include "source_base/global_variable.h" #include "source_base/math_integral.h" #include "source_base/spherical_bessel_transformer.h" -#include "source_io/module_parameter/parameter.h" using ModuleBase::PI; @@ -154,7 +153,11 @@ void NumericalRadial::build(const int l, set_icut(for_r_space, !for_r_space); } -void NumericalRadial::to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm, const int nk_legacy, const double lcao_dk) const +void NumericalRadial::to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm, + const int nk_legacy, + const double lcao_dk, + const bool out_element_info, + const bool cal_force) const { #ifdef __DEBUG assert(rgrid_); @@ -171,7 +174,7 @@ void NumericalRadial::to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm, orbital_lm.set_orbital_info(symbol_, itype_, l_, izeta_, std::min(nr_, ircut_+1), rab, rgrid_, Numerical_Orbital_Lm::Psi_Type::Psi, rvalue_, nk_legacy, lcao_dk, - 0.001 /* dr_uniform */, PARAM.inp.out_element_info, true, PARAM.inp.cal_force); + 0.001 /* dr_uniform */, out_element_info, true, cal_force); delete[] rab; } diff --git a/source/source_basis/module_nao/numerical_radial.h b/source/source_basis/module_nao/numerical_radial.h index f89a604ab62..6fadf402341 100644 --- a/source/source_basis/module_nao/numerical_radial.h +++ b/source/source_basis/module_nao/numerical_radial.h @@ -109,9 +109,11 @@ class NumericalRadial * use the k grid of NumericalRadial (which is FFT-compliant with r grid) to initialize * the k grid of Numerical_Orbital_Lm. */ - void to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm, + void to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm, const int nk_legacy = 4005, // equivalent to lcao_ecut = 1600 - const double lcao_dk = 0.01) const; + const double lcao_dk = 0.01, + const bool out_element_info = false, + const bool cal_force = false) const; /** * @brief Sets a SphericalBesselTransformer. diff --git a/source/source_basis/module_nao/radial_set.cpp b/source/source_basis/module_nao/radial_set.cpp index eade7423dd8..bb3efff3d85 100644 --- a/source/source_basis/module_nao/radial_set.cpp +++ b/source/source_basis/module_nao/radial_set.cpp @@ -85,13 +85,17 @@ RadialSet& RadialSet::operator=(const RadialSet& rhs) return *this; } -void RadialSet::to_numerical_orbital(Numerical_Orbital& no, const int nk_legacy, const double lcao_dk) const +void RadialSet::to_numerical_orbital(Numerical_Orbital& no, + const int nk_legacy, + const double lcao_dk, + const bool out_element_info, + const bool cal_force) const { no.chi().clear(); no.chi().resize(nchi_); for (int i = 0; i < nchi_; i++) { - chi_[i].to_numerical_orbital_lm(no.chi()[i], nk_legacy, lcao_dk); + chi_[i].to_numerical_orbital_lm(no.chi()[i], nk_legacy, lcao_dk, out_element_info, cal_force); } no.set_orbital_info(itype_, symbol_, lmax_, nzeta_, nchi_); diff --git a/source/source_basis/module_nao/radial_set.h b/source/source_basis/module_nao/radial_set.h index f03f7f34b82..09dd7d8ba93 100644 --- a/source/source_basis/module_nao/radial_set.h +++ b/source/source_basis/module_nao/radial_set.h @@ -143,7 +143,9 @@ class RadialSet */ virtual void to_numerical_orbital(Numerical_Orbital&, const int nk_legacy = 4005, // equivalent to lcao_ecut = 1600 - const double lcao_dk = 0.01 + const double lcao_dk = 0.01, + const bool out_element_info = false, + const bool cal_force = false ) const; /** diff --git a/source/source_basis/module_nao/two_center_bundle.cpp b/source/source_basis/module_nao/two_center_bundle.cpp index 4b248204b88..c2516206083 100644 --- a/source/source_basis/module_nao/two_center_bundle.cpp +++ b/source/source_basis/module_nao/two_center_bundle.cpp @@ -208,7 +208,9 @@ void TwoCenterBundle::to_LCAO_Orbitals(LCAO_Orbitals& ORB, const double lcao_ecut, const double lcao_dk, const double lcao_dr, - const double lcao_rmax) const + const double lcao_rmax, + const bool out_element_info, + const bool cal_force) const { ORB.ntype = orb_->ntype(); ORB.lmax = orb_->lmax(); @@ -240,7 +242,7 @@ void TwoCenterBundle::to_LCAO_Orbitals(LCAO_Orbitals& ORB, ORB.Phi = new Numerical_Orbital[orb_->ntype()]; for (int itype = 0; itype < orb_->ntype(); ++itype) { - (*orb_)(itype).to_numerical_orbital(ORB.Phi[itype], ORB.kmesh, ORB.dk); + (*orb_)(itype).to_numerical_orbital(ORB.Phi[itype], ORB.kmesh, ORB.dk, out_element_info, cal_force); } if (PARAM.globalv.deepks_setorb) @@ -252,7 +254,7 @@ void TwoCenterBundle::to_LCAO_Orbitals(LCAO_Orbitals& ORB, ORB.Alpha = new Numerical_Orbital[alpha_->ntype()]; for (int itype = 0; itype < alpha_->ntype(); ++itype) { - (*alpha_)(itype).to_numerical_orbital(ORB.Alpha[itype], ORB.kmesh, ORB.dk); + (*alpha_)(itype).to_numerical_orbital(ORB.Alpha[itype], ORB.kmesh, ORB.dk, out_element_info, cal_force); } } } diff --git a/source/source_basis/module_nao/two_center_bundle.h b/source/source_basis/module_nao/two_center_bundle.h index b2708a9dadf..49ae891f786 100644 --- a/source/source_basis/module_nao/two_center_bundle.h +++ b/source/source_basis/module_nao/two_center_bundle.h @@ -37,7 +37,9 @@ class TwoCenterBundle const double lcao_ecut, const double lcao_dk, const double lcao_dr, - const double lcao_rmax) const; + const double lcao_rmax, + const bool out_element_info, + const bool cal_force) const; std::unique_ptr kinetic_orb; std::unique_ptr overlap_orb; diff --git a/source/source_lcao/LCAO_init_basis.cpp b/source/source_lcao/LCAO_init_basis.cpp index c18e859599a..6bcad987463 100644 --- a/source/source_lcao/LCAO_init_basis.cpp +++ b/source/source_lcao/LCAO_init_basis.cpp @@ -49,7 +49,8 @@ void init_basis_lcao(Parallel_Orbitals& pv, // TODO Due to the omnipresence of LCAO_Orbitals, we still have to rely // on the old interface for now. - two_center_bundle.to_LCAO_Orbitals(orb, lcao_ecut, lcao_dk, lcao_dr, lcao_rmax); + two_center_bundle.to_LCAO_Orbitals(orb, lcao_ecut, lcao_dk, lcao_dr, lcao_rmax, + PARAM.inp.out_element_info, PARAM.inp.cal_force); if (PARAM.inp.vnl_in_h) { diff --git a/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp b/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp index 2fe6d46147f..08ce82142a0 100644 --- a/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp +++ b/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp @@ -308,7 +308,8 @@ LR::ESolver_LR::ESolver_LR(const Input_para& inp, UnitCell& ucell) : inpu two_center_bundle_.build_orb(ucell.ntype, ucell.orbital_fn.data()); LCAO_Orbitals orb; - two_center_bundle_.to_LCAO_Orbitals(orb, inp.lcao_ecut, inp.lcao_dk, inp.lcao_dr, inp.lcao_rmax); + two_center_bundle_.to_LCAO_Orbitals(orb, inp.lcao_ecut, inp.lcao_dk, inp.lcao_dr, inp.lcao_rmax, + inp.out_element_info, inp.cal_force); orb_cutoff_ = orb.cutoffs(); if (LR_Util::tolower(input.abs_gauge) == "velocity") { diff --git a/source/source_lcao/module_lr/lr_spectrum_velocity.cpp b/source/source_lcao/module_lr/lr_spectrum_velocity.cpp index 5691b5df832..8297a14cbea 100644 --- a/source/source_lcao/module_lr/lr_spectrum_velocity.cpp +++ b/source/source_lcao/module_lr/lr_spectrum_velocity.cpp @@ -15,7 +15,8 @@ namespace LR // convert the orbital object to the old class for Velocity_op LCAO_Orbitals orb; const auto& inp = PARAM.inp; - two_center_bundle.to_LCAO_Orbitals(orb, inp.lcao_ecut, inp.lcao_dk, inp.lcao_dr, inp.lcao_rmax); + two_center_bundle.to_LCAO_Orbitals(orb, inp.lcao_ecut, inp.lcao_dk, inp.lcao_dr, inp.lcao_rmax, + inp.out_element_info, inp.cal_force); // actually this class calculates the velocity matrix v(R) at A=0 Velocity_op> vR(&ucell, &gd, &pmat, orb, two_center_bundle.overlap_orb.get()); vR.calculate_vcomm_r(); // $<\mu, 0|[Vnl, r]|\nu, R>$ From ec78aac5c6f4f33a5a3b8e9d6001b19eefddb98a Mon Sep 17 00:00:00 2001 From: Critsium Date: Wed, 20 May 2026 14:39:58 +0800 Subject: [PATCH 3/5] Remove parameter.h dependency in pw_basis --- source/source_base/tool_quit.cpp | 10 ++++++++-- source/source_base/tool_quit.h | 12 +++++++++++- source/source_basis/module_pw/pw_basis_k.cpp | 1 - source/source_basis/module_pw/pw_basis_sup.cpp | 2 -- source/source_basis/module_pw/pw_distributeg.cpp | 4 +--- source/source_main/driver.cpp | 1 + 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/source/source_base/tool_quit.cpp b/source/source_base/tool_quit.cpp index 40943301b69..1ff4044c94d 100644 --- a/source/source_base/tool_quit.cpp +++ b/source/source_base/tool_quit.cpp @@ -17,6 +17,7 @@ namespace ModuleBase namespace { std::string g_quit_out_dir; +std::string g_quit_calculation; } void set_quit_out_dir(const std::string& dir) @@ -24,6 +25,11 @@ void set_quit_out_dir(const std::string& dir) g_quit_out_dir = dir; } +void set_quit_calculation(const std::string& calculation) +{ + g_quit_calculation = calculation; +} + //========================================================== // GLOBAL FUNCTION : // NAME : WARNING( write information into GlobalV::ofs_warning) @@ -139,7 +145,7 @@ void WARNING_QUIT(const std::string &file,const std::string &description,int ret //Check and print warning information for all cores. //Maybe in the future warning.log should be replaced by error.log. -void CHECK_WARNING_QUIT(const bool error_in, const std::string &file,const std::string &calculation,const std::string &description) +void CHECK_WARNING_QUIT(const bool error_in, const std::string &file, const std::string &description) { #ifdef __NORMAL if(error_in) std::cout << description << std::endl; @@ -150,7 +156,7 @@ void CHECK_WARNING_QUIT(const bool error_in, const std::string &file,const std:: std::cout.clear(); if(!GlobalV::ofs_running.is_open()) { - std::string logfile = g_quit_out_dir + "running_" + calculation + ".log"; + std::string logfile = g_quit_out_dir + "running_" + g_quit_calculation + ".log"; GlobalV::ofs_running.open( logfile.c_str(), std::ios::app ); } if(!GlobalV::ofs_warning.is_open()) diff --git a/source/source_base/tool_quit.h b/source/source_base/tool_quit.h index 7ba59aaf9e2..3ebdcfbd459 100644 --- a/source/source_base/tool_quit.h +++ b/source/source_base/tool_quit.h @@ -37,6 +37,16 @@ void WARNING(const std::string &file, const std::string &description); */ void set_quit_out_dir(const std::string& dir); +/** + * @brief Inject the calculation tag used by CHECK_WARNING_QUIT to compose the + * fallback log filename ("running_.log") when ofs_running + * is not already open. + * + * Caller-injected (typically once after input parameters are read). + * If never set, the fallback filename uses an empty tag. + */ +void set_quit_calculation(const std::string& calculation); + /** * @brief Close .log files and exit * @@ -71,7 +81,7 @@ void set_quit_out_dir(const std::string& dir); * @param file The file where warning happens * @param description The warning information */ -void CHECK_WARNING_QUIT(const bool error, const std::string &file,const std::string &calculation,const std::string &description); +void CHECK_WARNING_QUIT(const bool error, const std::string &file, const std::string &description); } // namespace ModuleBase diff --git a/source/source_basis/module_pw/pw_basis_k.cpp b/source/source_basis/module_pw/pw_basis_k.cpp index 0eecfb6099b..f76fe599048 100644 --- a/source/source_basis/module_pw/pw_basis_k.cpp +++ b/source/source_basis/module_pw/pw_basis_k.cpp @@ -157,7 +157,6 @@ void PW_Basis_K::setupIndGk() } ModuleBase::CHECK_WARNING_QUIT((ng == 0), "pw_basis_k.cpp", - PARAM.inp.calculation, no_pw_message); if (this->npwk_max < ng) { diff --git a/source/source_basis/module_pw/pw_basis_sup.cpp b/source/source_basis/module_pw/pw_basis_sup.cpp index 43eb044a5f8..2a0d464ce0e 100644 --- a/source/source_basis/module_pw/pw_basis_sup.cpp +++ b/source/source_basis/module_pw/pw_basis_sup.cpp @@ -1,6 +1,5 @@ #include "source_base/timer.h" #include "pw_basis.h" -#include "source_io/module_parameter/parameter.h" namespace ModulePW { @@ -61,7 +60,6 @@ void PW_Basis_Sup::distribute_g(const ModulePW::PW_Basis* pw_rho) this->distribution_method3(pw_rho); ModuleBase::CHECK_WARNING_QUIT((this->npw == 0), "pw_distributeg.cpp", - PARAM.inp.calculation, "Current core has no plane waves! Please reduce the cores."); ModuleBase::timer::end(this->classname, "distributeg"); return; diff --git a/source/source_basis/module_pw/pw_distributeg.cpp b/source/source_basis/module_pw/pw_distributeg.cpp index ea026e88d41..a13fc57f9b9 100644 --- a/source/source_basis/module_pw/pw_distributeg.cpp +++ b/source/source_basis/module_pw/pw_distributeg.cpp @@ -2,7 +2,6 @@ #include "source_base/tool_quit.h" #include "source_base/global_function.h" #include "source_base/timer.h" -#include "source_io/module_parameter/parameter.h" namespace ModulePW { /** @@ -26,8 +25,7 @@ void PW_Basis::distribute_g() ModuleBase::WARNING_QUIT("divide", "No such division type."); } const char* no_pw_message = "Current core has no plane waves! Please reduce the cores."; - ModuleBase::CHECK_WARNING_QUIT((this->npw == 0), "pw_distributeg.cpp", PARAM.inp.calculation, - no_pw_message); + ModuleBase::CHECK_WARNING_QUIT((this->npw == 0), "pw_distributeg.cpp", no_pw_message); ModuleBase::timer::end(this->classname, "distributeg"); return; } diff --git a/source/source_main/driver.cpp b/source/source_main/driver.cpp index 93e98ee461d..155f18a0f6d 100644 --- a/source/source_main/driver.cpp +++ b/source/source_main/driver.cpp @@ -124,6 +124,7 @@ void Driver::reading() input.read_parameters(PARAM, PARAM.globalv.global_in_card); ModuleBase::set_quit_out_dir(PARAM.globalv.global_out_dir); + ModuleBase::set_quit_calculation(PARAM.inp.calculation); #if defined(__CUDA) && defined(__USE_NVTX) ModuleBase::timer::set_nvtx_enabled(PARAM.inp.timer_enable_nvtx); From 4b94e7a32d97c8b65a75f432f8986272fb6ea088 Mon Sep 17 00:00:00 2001 From: Critsium Date: Wed, 20 May 2026 16:17:18 +0800 Subject: [PATCH 4/5] Remove dependency in pw_basis_k --- source/source_base/module_device/memory_op.cpp | 5 +++++ source/source_base/module_device/memory_op.h | 3 +++ source/source_basis/module_pw/pw_basis_k.cpp | 5 ++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/source/source_base/module_device/memory_op.cpp b/source/source_base/module_device/memory_op.cpp index d22b96c3cad..af5bacc6eec 100644 --- a/source/source_base/module_device/memory_op.cpp +++ b/source/source_base/module_device/memory_op.cpp @@ -452,6 +452,11 @@ void set_dsp_cluster_id(int id) g_dsp_cluster_id = id; } +int get_dsp_cluster_id() +{ + return g_dsp_cluster_id; +} + template struct resize_memory_op_mt { diff --git a/source/source_base/module_device/memory_op.h b/source/source_base/module_device/memory_op.h index d9e95c7adb0..5e292c57a65 100644 --- a/source/source_base/module_device/memory_op.h +++ b/source/source_base/module_device/memory_op.h @@ -225,6 +225,9 @@ struct delete_memory_op /// Defaults to 0 if never set. void set_dsp_cluster_id(int id); +/// @brief Read back the injected DSP cluster id. Returns 0 if never set. +int get_dsp_cluster_id(); + template struct resize_memory_op_mt { diff --git a/source/source_basis/module_pw/pw_basis_k.cpp b/source/source_basis/module_pw/pw_basis_k.cpp index f76fe599048..2c2d02bf927 100644 --- a/source/source_basis/module_pw/pw_basis_k.cpp +++ b/source/source_basis/module_pw/pw_basis_k.cpp @@ -1,10 +1,9 @@ #include "pw_basis_k.h" #include "source_base/constants.h" -#include "source_base/global_variable.h" #include "source_base/memory_recorder.h" +#include "source_base/module_device/memory_op.h" #include "source_base/timer.h" -#include "source_io/module_parameter/parameter.h" #include namespace ModulePW @@ -215,7 +214,7 @@ void PW_Basis_K::setuptransform() std::string fft_device = this->device; #if defined(__DSP) fft_device = "dsp"; - this->fft_bundle.set_dsp_cluster_id(GlobalV::MY_RANK % PARAM.inp.dsp_count); + this->fft_bundle.set_dsp_cluster_id(base_device::memory::get_dsp_cluster_id()); #endif this->fft_bundle.setfft(fft_device, this->precision); if (this->xprime) From f35b3cc96de9e75b3ce7e38fa3d4878640e6a7dc Mon Sep 17 00:00:00 2001 From: Critsium Date: Fri, 22 May 2026 17:12:21 +0800 Subject: [PATCH 5/5] refactor(source_basis): remove last parameter.h dependencies Decouple module_ao and module_nao from source_io/parameter.h: - ORB_atomic_lm / ORB_nonlocal_lm: replace PARAM.globalv.global_out_dir with ModuleBase::get_quit_out_dir() (new getter mirroring the existing set_quit_out_dir injection point). - two_center_bundle: thread orbital_dir as a build_orb parameter; replace the two deepks_setorb guards with ndesc>0 / alpha_ non-null checks that are equivalent under the build_alpha invariant. source_basis is now free of parameter.h. Co-Authored-By: Claude Opus 4.7 (1M context) --- source/source_base/tool_quit.cpp | 5 +++++ source/source_base/tool_quit.h | 6 ++++++ source/source_basis/module_ao/ORB_atomic_lm.cpp | 13 +++++++------ source/source_basis/module_ao/ORB_nonlocal_lm.cpp | 8 ++++---- .../source_basis/module_nao/two_center_bundle.cpp | 11 +++++------ source/source_basis/module_nao/two_center_bundle.h | 2 +- source/source_lcao/LCAO_init_basis.cpp | 2 +- source/source_lcao/module_lr/esolver_lrtd_lcao.cpp | 2 +- 8 files changed, 30 insertions(+), 19 deletions(-) diff --git a/source/source_base/tool_quit.cpp b/source/source_base/tool_quit.cpp index 1ff4044c94d..830145b5f4b 100644 --- a/source/source_base/tool_quit.cpp +++ b/source/source_base/tool_quit.cpp @@ -25,6 +25,11 @@ void set_quit_out_dir(const std::string& dir) g_quit_out_dir = dir; } +const std::string& get_quit_out_dir() +{ + return g_quit_out_dir; +} + void set_quit_calculation(const std::string& calculation) { g_quit_calculation = calculation; diff --git a/source/source_base/tool_quit.h b/source/source_base/tool_quit.h index 3ebdcfbd459..20234ab919a 100644 --- a/source/source_base/tool_quit.h +++ b/source/source_base/tool_quit.h @@ -37,6 +37,12 @@ void WARNING(const std::string &file, const std::string &description); */ void set_quit_out_dir(const std::string& dir); +/** + * @brief Read back the injected global output directory. + * Returns an empty string if set_quit_out_dir was never called. + */ +const std::string& get_quit_out_dir(); + /** * @brief Inject the calculation tag used by CHECK_WARNING_QUIT to compose the * fallback log filename ("running_.log") when ofs_running diff --git a/source/source_basis/module_ao/ORB_atomic_lm.cpp b/source/source_basis/module_ao/ORB_atomic_lm.cpp index d3542e021e3..ba524a0c92c 100644 --- a/source/source_basis/module_ao/ORB_atomic_lm.cpp +++ b/source/source_basis/module_ao/ORB_atomic_lm.cpp @@ -1,6 +1,7 @@ #include "ORB_atomic_lm.h" #include "source_base/sph_bessel_recursive.h" -#include "source_io/module_parameter/parameter.h" +#include "source_base/global_variable.h" +#include "source_base/tool_quit.h" #include "source_base/module_external/blas_connector.h" #include "source_base/timer.h" #include "source_base/math_integral.h" @@ -383,7 +384,7 @@ void Numerical_Orbital_Lm::use_uniform(const double &dr_uniform_in) if(GlobalV::MY_RANK==0) { std::stringstream ss; - ss << PARAM.globalv.global_out_dir << this->label << "/" + ss << ModuleBase::get_quit_out_dir() << this->label << "/" << this->label << "-" << orbital_type << ".ORBITAL_NOR_uniform.txt"; std::ofstream ofs(ss.str().c_str()); @@ -722,16 +723,16 @@ void Numerical_Orbital_Lm::plot(void)const if(GlobalV::MY_RANK==0) { std::stringstream ssr, ssk, ssru ,ssdru; // 2013-08-10 pengfei - ssr << PARAM.globalv.global_out_dir << this->label << "/" + ssr << ModuleBase::get_quit_out_dir() << this->label << "/" << this->label << "-"<< orbital_type << index_chi+1 << "-orbital-r.dat"; - ssk << PARAM.globalv.global_out_dir << this->label << "/" + ssk << ModuleBase::get_quit_out_dir() << this->label << "/" << this->label << "-" << orbital_type << index_chi+1 << "-orbital-k.dat"; - ssru << PARAM.globalv.global_out_dir << this->label << "/" + ssru << ModuleBase::get_quit_out_dir() << this->label << "/" << this->label << "-" << orbital_type << index_chi+1 << "-orbital-ru.dat"; - ssdru << PARAM.globalv.global_out_dir << this->label << "/" // 2013-08-10 pengfei + ssdru << ModuleBase::get_quit_out_dir() << this->label << "/" // 2013-08-10 pengfei << this->label << "-" << orbital_type << index_chi+1 << "-orbital-dru.dat"; std::ofstream ofsr(ssr.str().c_str()); diff --git a/source/source_basis/module_ao/ORB_nonlocal_lm.cpp b/source/source_basis/module_ao/ORB_nonlocal_lm.cpp index fd7dfab16cc..30f34a4ba7b 100644 --- a/source/source_basis/module_ao/ORB_nonlocal_lm.cpp +++ b/source/source_basis/module_ao/ORB_nonlocal_lm.cpp @@ -7,7 +7,7 @@ #include "source_base/math_sphbes.h" #include "source_base/mathzone.h" /// use Polynomial_Interpolation_xy, Spherical_Bessel #include "source_base/mathzone_add1.h" /// use SplineD2 -#include "source_io/module_parameter/parameter.h" +#include "source_base/tool_quit.h" #include #include @@ -237,13 +237,13 @@ void Numerical_Nonlocal_Lm::plot(const int &my_rank)const if(my_rank==0) { std::stringstream ssr, ssk, ssru; - ssr << PARAM.globalv.global_out_dir << this->label << "/" + ssr << ModuleBase::get_quit_out_dir() << this->label << "/" << this->label << "-" << orbital_type << "-proj-r.dat"; - ssk << PARAM.globalv.global_out_dir << this->label << "/" + ssk << ModuleBase::get_quit_out_dir() << this->label << "/" << this->label << "-" << orbital_type << "-proj-k.dat"; - ssru << PARAM.globalv.global_out_dir << this->label << "/" + ssru << ModuleBase::get_quit_out_dir() << this->label << "/" << this->label << "-" << orbital_type << "-proj-ru.dat"; std::ofstream ofsr(ssr.str().c_str()); diff --git a/source/source_basis/module_nao/two_center_bundle.cpp b/source/source_basis/module_nao/two_center_bundle.cpp index c2516206083..9e9ceea5ff4 100644 --- a/source/source_basis/module_nao/two_center_bundle.cpp +++ b/source/source_basis/module_nao/two_center_bundle.cpp @@ -5,17 +5,16 @@ #include "source_base/parallel_common.h" #include "source_base/ylm.h" #include "source_basis/module_nao/real_gaunt_table.h" -#include "source_io/module_parameter/parameter.h" #include -void TwoCenterBundle::build_orb(int ntype, const std::string* file_orb0) +void TwoCenterBundle::build_orb(int ntype, const std::string* file_orb0, const std::string& orbital_dir) { std::vector file_orb(ntype); if (GlobalV::MY_RANK == 0) { - std::transform(file_orb0, file_orb0 + ntype, file_orb.begin(), [](const std::string& file) { - return PARAM.inp.orbital_dir + file; + std::transform(file_orb0, file_orb0 + ntype, file_orb.begin(), [&orbital_dir](const std::string& file) { + return orbital_dir + file; }); } #ifdef __MPI @@ -34,7 +33,7 @@ void TwoCenterBundle::build_beta(int ntype, Numerical_Nonlocal* nl) void TwoCenterBundle::build_alpha(int ndesc, std::string* file_desc0) { - if (PARAM.globalv.deepks_setorb) + if (ndesc > 0) { std::vector file_desc(ndesc); if (GlobalV::MY_RANK == 0) @@ -245,7 +244,7 @@ void TwoCenterBundle::to_LCAO_Orbitals(LCAO_Orbitals& ORB, (*orb_)(itype).to_numerical_orbital(ORB.Phi[itype], ORB.kmesh, ORB.dk, out_element_info, cal_force); } - if (PARAM.globalv.deepks_setorb) + if (alpha_) { ORB.lmax_d = alpha_->lmax(); ORB.nchimax_d = alpha_->nzeta_max(); diff --git a/source/source_basis/module_nao/two_center_bundle.h b/source/source_basis/module_nao/two_center_bundle.h index 49ae891f786..1e1db87ca43 100644 --- a/source/source_basis/module_nao/two_center_bundle.h +++ b/source/source_basis/module_nao/two_center_bundle.h @@ -15,7 +15,7 @@ class TwoCenterBundle TwoCenterBundle& operator=(TwoCenterBundle&&) = default; // NOTE: some variables might be set only on RANK-0 - void build_orb(int ntype, const std::string* file_orb0); + void build_orb(int ntype, const std::string* file_orb0, const std::string& orbital_dir); void build_beta(int ntype, Numerical_Nonlocal* nl); void build_alpha(int ndesc = 0, std::string* file_desc0 = nullptr); void build_orb_onsite(const double& radius); diff --git a/source/source_lcao/LCAO_init_basis.cpp b/source/source_lcao/LCAO_init_basis.cpp index 6bcad987463..e525ecf3708 100644 --- a/source/source_lcao/LCAO_init_basis.cpp +++ b/source/source_lcao/LCAO_init_basis.cpp @@ -41,7 +41,7 @@ void init_basis_lcao(Parallel_Orbitals& pv, // * reading the localized orbitals/projectors // * construct the interpolation tables. - two_center_bundle.build_orb(ucell.ntype, ucell.orbital_fn.data()); + two_center_bundle.build_orb(ucell.ntype, ucell.orbital_fn.data(), PARAM.inp.orbital_dir); two_center_bundle.build_alpha(PARAM.globalv.deepks_setorb, &ucell.descriptor_file); two_center_bundle.build_orb_onsite(onsite_radius); // currently deepks only use one descriptor file, so cast bool to int is diff --git a/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp b/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp index 08ce82142a0..71b9b961202 100644 --- a/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp +++ b/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp @@ -305,7 +305,7 @@ LR::ESolver_LR::ESolver_LR(const Input_para& inp, UnitCell& ucell) : inpu this->parameter_check(); /// read orbitals and build the interpolation table - two_center_bundle_.build_orb(ucell.ntype, ucell.orbital_fn.data()); + two_center_bundle_.build_orb(ucell.ntype, ucell.orbital_fn.data(), inp.orbital_dir); LCAO_Orbitals orb; two_center_bundle_.to_LCAO_Orbitals(orb, inp.lcao_ecut, inp.lcao_dk, inp.lcao_dr, inp.lcao_rmax,