diff --git a/source/source_base/tool_quit.cpp b/source/source_base/tool_quit.cpp index 1ff4044c94..830145b5f4 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 3ebdcfbd45..20234ab919 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 d3542e021e..ba524a0c92 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 fd7dfab16c..30f34a4ba7 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 c251620608..9e9ceea5ff 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 49ae891f78..1e1db87ca4 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 6bcad98746..e525ecf370 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 08ce82142a..71b9b96120 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,