diff --git a/source/module_elecstate/module_charge/charge_init.cpp b/source/module_elecstate/module_charge/charge_init.cpp index 57af45e3be..b41db4047f 100644 --- a/source/module_elecstate/module_charge/charge_init.cpp +++ b/source/module_elecstate/module_charge/charge_init.cpp @@ -157,7 +157,25 @@ void Charge::init_rho(elecstate::efermi& eferm_iout, { for (int is = 0; is < PARAM.inp.nspin; ++is) { - GlobalC::restart.load_disk("charge", is, this->nrxx, rho[is]); + try + { + GlobalC::restart.load_disk("charge", is, this->nrxx, rho[is]); + } + catch (const std::exception& e) + { + // try to load from the output of `out_chg` + std::stringstream ssc; + ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_CHG.cube"; + if (ModuleIO::read_vdata_palgrid(GlobalC::Pgrid, + (PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK), + GlobalV::ofs_running, + ssc.str(), + this->rho[is], + GlobalC::ucell.nat)) + { + GlobalV::ofs_running << " Read in the charge density: " << ssc.str() << std::endl; + } + } } GlobalC::restart.info_load.load_charge_finish = true; } diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.hpp b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.hpp index 13572cc8e9..56dc6f1f4d 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.hpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.hpp @@ -205,7 +205,7 @@ OperatorEXX>::OperatorEXX(HS_Matrix_K* hsk_in, else if (this->add_hexx_type == Add_Hexx_Type::R) { // read in Hexx(R) - const std::string restart_HR_path = GlobalC::restart.folder + "HexxR" + std::to_string(GlobalV::MY_RANK); + const std::string restart_HR_path = PARAM.globalv.global_readin_dir + "HexxR" + std::to_string(GlobalV::MY_RANK); bool all_exist = true; for (int is = 0; is < PARAM.inp.nspin; ++is) { diff --git a/source/module_ri/Exx_LRI_interface.hpp b/source/module_ri/Exx_LRI_interface.hpp index 5f7ba2b964..72d4b686ca 100644 --- a/source/module_ri/Exx_LRI_interface.hpp +++ b/source/module_ri/Exx_LRI_interface.hpp @@ -141,8 +141,14 @@ void Exx_LRI_Interface::exx_hamilt2density(elecstate::ElecState& elec, if (GlobalC::restart.info_load.load_H_finish && !GlobalC::restart.info_load.restart_exx && this->two_level_step == 0 && iter == 1) { - if (GlobalV::MY_RANK == 0) {GlobalC::restart.load_disk("Eexx", 0, 1, &this->exx_ptr->Eexx); -} + if (GlobalV::MY_RANK == 0) + { + try { GlobalC::restart.load_disk("Eexx", 0, 1, &this->exx_ptr->Eexx); } + catch (const std::exception& e) + { + std::cout << "WARNING: Cannot read Eexx from disk, the energy of the 1st loop will be wrong, sbut it does not influence the subsequent loops." << std::endl; + } + } Parallel_Common::bcast_double(this->exx_ptr->Eexx); this->exx_ptr->Eexx /= GlobalC::exx_info.info_global.hybrid_alpha; }