From eba47671a97f1f3a70c37fb81ecd9d9bb160dd3b Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sat, 7 Mar 2026 20:13:55 +0800 Subject: [PATCH 01/13] fix some small places in source_base --- source/source_base/matrix.cpp | 29 ----------------------------- source/source_base/matrix.h | 4 ++-- source/source_base/vector3.h | 3 ++- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/source/source_base/matrix.cpp b/source/source_base/matrix.cpp index 7d58a7c867b..f047f48462f 100644 --- a/source/source_base/matrix.cpp +++ b/source/source_base/matrix.cpp @@ -323,35 +323,6 @@ double matrix::trace_on(void) const return tr; } -//this function is wrong, and there is no file use this function. -// void matrix::get_extreme_eigen_values(double &ev_lower, double &ev_upper)const -// { -// double *a = new double[nr]; -// double *b = new double[nr]; -// for (int i = 0; i < nr; ++i) -// { -// double sum = 0.0; -// for(int j = 0; j < nc; ++j) -// { -// sum += fabs(c[i * nc + j]); -// } -// sum -= fabs(c[i * nc + i]); -// a[i] = c[i * nc + i] - sum; -// b[i] = c[i * nc + i] + sum; -// } - -// ev_lower = a[0]; -// ev_upper = b[0]; - -// for (int i = 1; i < nr; ++i) -// { -// if (a[i] < ev_lower) ev_lower = a[i]; -// if (b[i] > ev_upper) ev_upper = b[i]; -// } -// delete[] a; -// delete[] b; -// } - // Peize Lin add 2017-05-27 void matrix::reshape( const int nr_new, const int nc_new, const bool flag_zero ) { diff --git a/source/source_base/matrix.h b/source/source_base/matrix.h index d4c9cb51b64..0a117b4ca1a 100644 --- a/source/source_base/matrix.h +++ b/source/source_base/matrix.h @@ -10,7 +10,7 @@ #include #include -#include// test +#include // test namespace ModuleBase { @@ -80,7 +80,7 @@ class matrix std::ostream & print( std::ostream & os, const double threshold=0.0 ) const; // Peize Lin add 2021.09.08 - using type=double; // Peiae Lin add 2022.08.08 for template + using type=double; // Peize Lin add 2022.08.08 for template }; diff --git a/source/source_base/vector3.h b/source/source_base/vector3.h index 39cdbeb014c..6d0281038f9 100644 --- a/source/source_base/vector3.h +++ b/source/source_base/vector3.h @@ -389,7 +389,8 @@ template inline bool operator!=(const Vector3 &u, const Vector3 // whether u == v template inline bool operator==(const Vector3 &u, const Vector3 &v) { - if (u.x == v.x && u.y == v.y && u.z == v.z) + const T eps = 1e-15; + if (std::abs(u.x - v.x) < eps && std::abs(u.y - v.y) < eps && std::abs(u.z - v.z) < eps) return true; return false; } From edcf7b123d252152a7d6c06c8441852db07495cf Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 05:26:59 +0800 Subject: [PATCH 02/13] refactor(cell_index): replace std::out_of_range with WARNING_QUIT Replace standard exception handling with project-specific error handling in cell_index.cpp to comply with ABACUS code style guidelines. Changes: - Replace 3 instances of 'throw std::out_of_range' with ModuleBase::WARNING_QUIT in functions: iw2l(), iw2z(), iw2m() - Remove unnecessary #include - Fix incorrect error message strings in iw2z() and iw2m() (was 'iw2l') This change follows the cpp-code-style skill rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions for error handling in the ABACUS project. --- source/source_cell/cell_index.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/source/source_cell/cell_index.cpp b/source/source_cell/cell_index.cpp index 75708dec76a..c30d0dff964 100644 --- a/source/source_cell/cell_index.cpp +++ b/source/source_cell/cell_index.cpp @@ -2,7 +2,6 @@ #include "source_base/name_angular.h" #include "source_base/tool_quit.h" -#include CellIndex::CellIndex(const std::vector& atomLabels_in, const std::vector& atomCounts_in, @@ -185,7 +184,7 @@ int CellIndex::iw2l(int iat, int iw) { ModuleBase::WARNING_QUIT("CellIndex::iw2l", "localized wave funciton index out of range [0, nw)"); } - throw std::out_of_range(std::string(__FILE__)+" line "+std::to_string(__LINE__)); + ModuleBase::WARNING_QUIT("CellIndex::iw2l", "unreachable code reached"); } int CellIndex::iw2z(int iat, int iw) @@ -208,9 +207,9 @@ int CellIndex::iw2z(int iat, int iw) } if (iw >= 0) { - ModuleBase::WARNING_QUIT("CellIndex::iw2l", "localized wave funciton index out of range [0, nw)"); + ModuleBase::WARNING_QUIT("CellIndex::iw2z", "localized wave funciton index out of range [0, nw)"); } - throw std::out_of_range(std::string(__FILE__)+" line "+std::to_string(__LINE__)); + ModuleBase::WARNING_QUIT("CellIndex::iw2z", "unreachable code reached"); } int CellIndex::iw2m(int iat, int iw) @@ -233,9 +232,9 @@ int CellIndex::iw2m(int iat, int iw) } if (iw >= 0) { - ModuleBase::WARNING_QUIT("CellIndex::iw2l", "localized wave funciton index out of range [0, nw)"); + ModuleBase::WARNING_QUIT("CellIndex::iw2m", "localized wave funciton index out of range [0, nw)"); } - throw std::out_of_range(std::string(__FILE__)+" line "+std::to_string(__LINE__)); + ModuleBase::WARNING_QUIT("CellIndex::iw2m", "unreachable code reached"); } bool CellIndex::check_nspin(int nspin) From 2ef595be611164206de613217f9bc2e5897fda8d Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 05:35:13 +0800 Subject: [PATCH 03/13] refactor(cell_index): add const qualifier to member functions Add const qualifier to all getter and helper member functions in CellIndex class to improve const-correctness according to cpp-code-style skill guidelines. Changes in cell_index.h: - Add const to all public getter functions: get_nat(), get_ntype(), get_nw(), get_iwt(), get_maxL(), get_nchi(), get_atom_label() - Add const to write_orb_info() and change parameter to const reference - Add const to private helper functions: iat2it(), iat2ia(), iw2l(), iw2z(), iw2m() Changes in cell_index.cpp: - Update all function definitions to match header declarations - Change write_orb_info parameter from std::string to const std::string& This follows the ABACUS code style rule that getter functions and functions that do not modify member state should be marked const. --- source/source_cell/cell_index.cpp | 30 +++++++++++++++--------------- source/source_cell/cell_index.h | 30 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/source/source_cell/cell_index.cpp b/source/source_cell/cell_index.cpp index c30d0dff964..c147afa936f 100644 --- a/source/source_cell/cell_index.cpp +++ b/source/source_cell/cell_index.cpp @@ -17,12 +17,12 @@ CellIndex::CellIndex(const std::vector& atomLabels_in, this->cal_orbitalCounts(); } -int CellIndex::get_ntype() +int CellIndex::get_ntype() const { return this->atomCounts.size(); } -int CellIndex::get_nat() +int CellIndex::get_nat() const { int nat = 0; for (int it = 0; it < this->atomCounts.size(); ++it) @@ -32,12 +32,12 @@ int CellIndex::get_nat() return nat; } -int CellIndex::get_nat(int it) +int CellIndex::get_nat(int it) const { return this->atomCounts[it]; } -int CellIndex::get_nw() +int CellIndex::get_nw() const { int nw = 0; for (int it = 0; it < this->orbitalCounts.size(); ++it) @@ -47,13 +47,13 @@ int CellIndex::get_nw() return nw; } -int CellIndex::get_nw(int iat) +int CellIndex::get_nw(int iat) const { int it = this->iat2it(iat); return this->orbitalCounts[it]; } -int CellIndex::get_iwt(int iat, int orbital_index) +int CellIndex::get_iwt(int iat, int orbital_index) const { if (iat < 0 || iat >= this->get_nat()) { @@ -82,14 +82,14 @@ int CellIndex::get_iwt(int iat, int orbital_index) return iwt; } -int CellIndex::get_maxL(int iat) +int CellIndex::get_maxL(int iat) const { int it = this->iat2it(iat); return this->lnchiCounts[it].size() - 1; } /// @brief get nchi -int CellIndex::get_nchi(int iat, int L) +int CellIndex::get_nchi(int iat, int L) const { int it = this->iat2it(iat); if (L < 0 || L >= this->lnchiCounts[it].size()) @@ -118,7 +118,7 @@ void CellIndex::check_atomCounts() } } -std::string CellIndex::get_atom_label(int iat, bool order) +std::string CellIndex::get_atom_label(int iat, bool order) const { int it = this->iat2it(iat); int ia = this->iat2ia(iat); @@ -128,7 +128,7 @@ std::string CellIndex::get_atom_label(int iat, bool order) return atomType; } -int CellIndex::iat2it(int iat) +int CellIndex::iat2it(int iat) const { int running_iat = 0; int it = -1; // Tracks the index of the atom in atomLabels @@ -150,7 +150,7 @@ int CellIndex::iat2it(int iat) return it; } -int CellIndex::iat2ia(int iat) +int CellIndex::iat2ia(int iat) const { int it = this->iat2it(iat); // sum of atoms of previous types @@ -162,7 +162,7 @@ int CellIndex::iat2ia(int iat) return iat - running_iat; } -int CellIndex::iw2l(int iat, int iw) +int CellIndex::iw2l(int iat, int iw) const { int it = this->iat2it(iat); int maxL = this->lnchiCounts[it].size() - 1; @@ -187,7 +187,7 @@ int CellIndex::iw2l(int iat, int iw) ModuleBase::WARNING_QUIT("CellIndex::iw2l", "unreachable code reached"); } -int CellIndex::iw2z(int iat, int iw) +int CellIndex::iw2z(int iat, int iw) const { int it = this->iat2it(iat); int maxL = this->lnchiCounts[it].size() - 1; @@ -212,7 +212,7 @@ int CellIndex::iw2z(int iat, int iw) ModuleBase::WARNING_QUIT("CellIndex::iw2z", "unreachable code reached"); } -int CellIndex::iw2m(int iat, int iw) +int CellIndex::iw2m(int iat, int iw) const { int it = this->iat2it(iat); int maxL = this->lnchiCounts[it].size() - 1; @@ -261,7 +261,7 @@ void CellIndex::cal_orbitalCounts() } } -void CellIndex::write_orb_info(std::string out_dir) +void CellIndex::write_orb_info(const std::string& out_dir) const { std::stringstream os; os << out_dir << "Orbital"; diff --git a/source/source_cell/cell_index.h b/source/source_cell/cell_index.h index caa2645e201..ed24e521906 100644 --- a/source/source_cell/cell_index.h +++ b/source/source_cell/cell_index.h @@ -28,25 +28,25 @@ class CellIndex public: /// @brief the total number of atoms - int get_nat(); + int get_nat() const; /// @brief the total number of atoms of a given type - int get_nat(int it); + int get_nat(int it) const; /// @brief get ntype - int get_ntype(); + int get_ntype() const; /// @brief get nw - int get_nw(); + int get_nw() const; /// @brief get nw of a given type - int get_nw(int iat); + int get_nw(int iat) const; /// @brief get iwt - int get_iwt(int iat, int orbital_index); + int get_iwt(int iat, int orbital_index) const; /// @brief get maximum L of a given atom - int get_maxL(int iat); + int get_maxL(int iat) const; /// @brief get nchi of a given atom and a give L - int get_nchi(int iat, int L); + int get_nchi(int iat, int L) const; /// @brief get atom label of a given atom - std::string get_atom_label(int iat, bool order = false); + std::string get_atom_label(int iat, bool order = false) const; /// @brief write orbital info into file - void write_orb_info(std::string out_dir); + void write_orb_info(const std::string& out_dir) const; private: /// atomCounts is a vector used to store the number of atoms for each type @@ -66,15 +66,15 @@ class CellIndex /// check if atomCounts is set ok void check_atomCounts(); /// get type of atom from total order - int iat2it(int iat); + int iat2it(int iat) const; /// get index of atom in the same type - int iat2ia(int iat); + int iat2ia(int iat) const; /// get L from iw - int iw2l(int iat, int iw); + int iw2l(int iat, int iw) const; /// get Z from iw - int iw2z(int iat, int iw); + int iw2z(int iat, int iw) const; /// get m from iw - int iw2m(int iat, int iw); + int iw2m(int iat, int iw) const; }; #endif // CELL_INDEX_H From 1032889974e1af895b7e0741032ffe35acef21af Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 05:41:06 +0800 Subject: [PATCH 04/13] =?UTF-8?q?fix(density=5Fmatrix):=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8WARNING=5FQUIT=E6=9B=BF=E4=BB=A3throw=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在density_matrix.cpp中添加了tool_quit.h头文件 - 将第616行的throw std::string替换为ModuleBase::WARNING_QUIT - 统一了项目的错误处理方式,符合ABACUS代码规范 修改文件: - source/source_estate/module_dm/density_matrix.cpp 影响范围:错误处理流程 --- source/source_estate/module_dm/density_matrix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/source_estate/module_dm/density_matrix.cpp b/source/source_estate/module_dm/density_matrix.cpp index e5ad1ba620b..97ca3032599 100644 --- a/source/source_estate/module_dm/density_matrix.cpp +++ b/source/source_estate/module_dm/density_matrix.cpp @@ -5,6 +5,7 @@ #include "source_base/memory.h" #include "source_base/timer.h" #include "source_base/tool_title.h" +#include "source_base/tool_quit.h" #include "source_base/constants.h" #include "source_cell/klist.h" @@ -612,7 +613,7 @@ void DensityMatrix::switch_dmr(const int mode) } break; default: - throw std::string("Unknown mode in switch_dmr"); + ModuleBase::WARNING_QUIT("density_matrix.cpp", "Unknown mode in switch_dmr"); } ModuleBase::timer::tick("DensityMatrix", "switch_dmr"); } From 4f52aaf5fec374b7d615822b4e46f72f66b89dc5 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 05:42:43 +0800 Subject: [PATCH 05/13] =?UTF-8?q?fix(symmetry=5Frotation):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DC++14=E6=B3=9B=E5=9E=8Blambda=E8=AF=AD=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E4=B8=BAC++11=E5=85=BC=E5=AE=B9=E5=86=99?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将泛型lambda [](auto x) 改为 [](double x) - 符合ABACUS项目只支持C++11标准的要求 - Matrix3的元素类型为double,无需泛型 修改文件: - source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation_output.cpp --- .../module_ri/module_exx_symmetry/symmetry_rotation_output.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation_output.cpp b/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation_output.cpp index 0e9e01a7d28..e92f4ad3672 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation_output.cpp +++ b/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation_output.cpp @@ -3,7 +3,7 @@ namespace ModuleSymmetry { std::string mat3_fmt(const ModuleBase::Matrix3& m) { - auto s = [](auto x) { return std::to_string(x); }; + auto s = [](double x) { return std::to_string(x); }; return s(m.e11) + " " + s(m.e12) + " " + s(m.e13) + "\n" + s(m.e21) + " " + s(m.e22) + " " + s(m.e23) + "\n" + s(m.e31) + " " + s(m.e32) + " " + s(m.e33); From 5682e00cda28685ae6253e2bd41a72c776e84f57 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 05:45:07 +0800 Subject: [PATCH 06/13] refactor(restart): replace std::runtime_error with WARNING_QUIT Replace standard exception handling with project-specific error handling in restart.cpp to comply with cpp-code-style skill guidelines. Changes: - Replace 4 instances of 'throw std::runtime_error' with ModuleBase::WARNING_QUIT in functions: write_file2() and read_file2() - Remove unnecessary #include - Add #include "source_base/tool_quit.h" This follows the ABACUS code style rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions. --- source/source_io/module_restart/restart.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/source_io/module_restart/restart.cpp b/source/source_io/module_restart/restart.cpp index c960215a2a6..cee2d954ac6 100644 --- a/source/source_io/module_restart/restart.cpp +++ b/source/source_io/module_restart/restart.cpp @@ -4,9 +4,9 @@ #include #include -#include #include "source_base/global_function.h" +#include "source_base/tool_quit.h" void Restart::write_file1(const std::string &file_name, const void*const ptr, const size_t size) const { @@ -25,7 +25,7 @@ bool Restart::write_file2(const std::string& file_name, const void* const ptr, c const int file = open(file_name.c_str(), O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR); if (-1 == file){ if (error_quit){ - throw std::runtime_error("can't open restart save file. \nerrno=" + ModuleBase::GlobalFunc::TO_STRING(errno) + ".\n" + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + ModuleBase::WARNING_QUIT("Restart::write_file2", "can't open restart save file. errno=" + ModuleBase::GlobalFunc::TO_STRING(errno)); } else { return false; } @@ -33,7 +33,7 @@ bool Restart::write_file2(const std::string& file_name, const void* const ptr, c auto error = write(file, ptr, size); if (-1 == error) { if (error_quit) { - throw std::runtime_error("can't write restart save file. \nerrno=" + ModuleBase::GlobalFunc::TO_STRING(errno) + ".\n" + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + ModuleBase::WARNING_QUIT("Restart::write_file2", "can't write restart save file. errno=" + ModuleBase::GlobalFunc::TO_STRING(errno)); } else { return false; } @@ -52,7 +52,7 @@ bool Restart::read_file2(const std::string& file_name, void* const ptr, const si const int file = open(file_name.c_str(), O_RDONLY); if (-1 == file) { if (error_quit) { - throw std::runtime_error("can't open restart load file. \nerrno=" + ModuleBase::GlobalFunc::TO_STRING(errno) + ".\n" + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + ModuleBase::WARNING_QUIT("Restart::read_file2", "can't open restart load file. errno=" + ModuleBase::GlobalFunc::TO_STRING(errno)); } else { return false; } @@ -60,11 +60,11 @@ bool Restart::read_file2(const std::string& file_name, void* const ptr, const si auto error = read(file, ptr, size); if (-1 == error) { if (error_quit) { - throw std::runtime_error("can't read restart load file. \nerrno=" + ModuleBase::GlobalFunc::TO_STRING(errno) + ".\n" + std::string(__FILE__) + " line " + std::to_string(__LINE__)); + ModuleBase::WARNING_QUIT("Restart::read_file2", "can't read restart load file. errno=" + ModuleBase::GlobalFunc::TO_STRING(errno)); } else { return false; } } close(file); return true; -} \ No newline at end of file +} From f0558c56b27ae4818c2fed9f52c9073c2f1c088c Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 05:47:00 +0800 Subject: [PATCH 07/13] refactor(write_libxc_r): replace std::exception with WARNING_QUIT Replace standard exception handling with project-specific error handling in write_libxc_r.cpp to comply with cpp-code-style skill guidelines. Changes: - Replace 9 instances of throw with ModuleBase::WARNING_QUIT - throw std::domain_error -> WARNING_QUIT - throw std::invalid_argument -> WARNING_QUIT - Remove #include - Add #include "source_base/tool_quit.h" This follows the ABACUS code style rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions. --- .../source_io/module_chgpot/write_libxc_r.cpp | 48 +++++-------------- 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/source/source_io/module_chgpot/write_libxc_r.cpp b/source/source_io/module_chgpot/write_libxc_r.cpp index e2a246bacf8..21df763f728 100644 --- a/source/source_io/module_chgpot/write_libxc_r.cpp +++ b/source/source_io/module_chgpot/write_libxc_r.cpp @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include "source_base/tool_quit.h" void ModuleIO::write_libxc_r( const int order, @@ -116,10 +116,7 @@ void ModuleIO::write_libxc_r( case 1: vrho .resize( nrxx * nspin ); case 0: exc .resize( nrxx ); break; - default: throw std::domain_error( - "order =" + std::to_string(order) + - " unfinished in " + std::string(__FILE__) + - " line " + std::to_string(__LINE__)); + default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported (must be 0-4)"); break; } if(is_gga) @@ -137,10 +134,7 @@ void ModuleIO::write_libxc_r( v2sigma2 .resize( nrxx * ((1==nspin)?1:6) ); case 1: vsigma .resize( nrxx * ((1==nspin)?1:3) ); case 0: break; - default: throw std::domain_error( - "order =" + std::to_string(order) + - " unfinished in " + std::string(__FILE__) + - " line " + std::to_string(__LINE__)); + default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported for GGA (must be 0-4)"); break; } } @@ -173,11 +167,8 @@ void ModuleIO::write_libxc_r( break; case 0: xc_lda_exc ( &func, nrxx, rho.data(), exc.data() ); break; - default: throw std::domain_error( - "order =" + std::to_string(order) + - " unfinished in " + std::string(__FILE__) + - " line " + std::to_string(__LINE__)); - break; + default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported for LDA (must be 0-4)"); + break; } break; } @@ -205,21 +196,14 @@ void ModuleIO::write_libxc_r( break; case 0: xc_gga_exc ( &func, nrxx, rho.data(), sigma.data(), exc.data() ); break; - default: throw std::domain_error( - "order =" + std::to_string(order) + - " unfinished in " + std::string(__FILE__) + - " line " + std::to_string(__LINE__)); + default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported for GGA (must be 0-4)"); break; } break; } default: - { - throw std::domain_error( - "func.info->family =" + std::to_string(func.info->family) + - " unfinished in " + std::string(__FILE__) + - " line " + std::to_string(__LINE__)); - break; + ModuleBase::WARNING_QUIT("write_libxc_r", "func.info->family =" + std::to_string(func.info->family) + " not supported"); + break; } } // end switch( func.info->family ) } // end for( xc_func_type &func : funcs ) @@ -258,11 +242,7 @@ void ModuleIO::write_libxc_r( pw_rhod.nz); #else if(nspin!=1) - { throw std::invalid_argument( - "nspin=" + std::to_string(nspin) + - " is invalid for ModuleIO::write_cube_core without MPI. see " + - std::string(__FILE__) + " line " + - std::to_string(__LINE__)); + { ModuleBase::WARNING_QUIT("write_libxc_r", "nspin=" + std::to_string(nspin) + " is invalid for ModuleIO::write_cube_core without MPI"); } ModuleIO::write_cube_core( ofs, @@ -294,10 +274,7 @@ void ModuleIO::write_libxc_r( case 1: write_data( "vrho" , vrho , nspin ); case 0: write_data( "exc" , exc , 1 ); break; - default: throw std::domain_error( - "order =" + std::to_string(order) + - " unfinished in " + std::string(__FILE__) + - " line " + std::to_string(__LINE__)); + default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported (must be 0-4)"); break; } if(is_gga) @@ -315,10 +292,7 @@ void ModuleIO::write_libxc_r( write_data( "v2sigma2" , v2sigma2 , (1==nspin)?1:6 ); case 1: write_data( "vsigma" , vsigma , (1==nspin)?1:3 ); case 0: break; - default: throw std::domain_error( - "order =" + std::to_string(order) + - " unfinished in " + std::string(__FILE__) + - " line " + std::to_string(__LINE__)); + default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported for GGA (must be 0-4)"); break; } } From 673fd8fcf598fa4533ff13ab629ded4e842bfef0 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 05:50:33 +0800 Subject: [PATCH 08/13] style: unify code indentation to 4-space in source_md files - Replace tabs with 4 spaces in md_func.cpp (lines 198-209) - Replace tabs with 4 spaces in md_base.cpp (line 65) - Replace tabs with 4 spaces in run_md.cpp (lines 59-61) --- source/source_md/md_base.cpp | 2 +- source/source_md/md_func.cpp | 24 ++++++++++++------------ source/source_md/run_md.cpp | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source/source_md/md_base.cpp b/source/source_md/md_base.cpp index 9e5b0e7c6aa..390e1c2b082 100644 --- a/source/source_md/md_base.cpp +++ b/source/source_md/md_base.cpp @@ -62,7 +62,7 @@ void MD_base::setup(ModuleESolver::ESolver* p_esolver, const std::string& global // mohan add 2026-01-04 const int stress_step = 0; - const int force_step = 0; + const int force_step = 0; const int istep_print = step_ + step_rst_ + 1; ModuleIO::print_screen(stress_step, force_step, istep_print); diff --git a/source/source_md/md_func.cpp b/source/source_md/md_func.cpp index d57815cc33f..df76de36f57 100644 --- a/source/source_md/md_func.cpp +++ b/source/source_md/md_func.cpp @@ -195,18 +195,18 @@ void init_vel(const UnitCell& unit_in, ModuleBase::Vector3 frozen; get_mass_mbl(unit_in, allmass, frozen, ionmbl); frozen_freedom = frozen.x + frozen.y + frozen.z; - if (frozen.x == 0) - { - ++frozen_freedom; - } - if (frozen.y == 0) - { - ++frozen_freedom; - } - if (frozen.z == 0) - { - ++frozen_freedom; - } + if (frozen.x == 0) + { + ++frozen_freedom; + } + if (frozen.y == 0) + { + ++frozen_freedom; + } + if (frozen.z == 0) + { + ++frozen_freedom; + } if (unit_in.init_vel) { diff --git a/source/source_md/run_md.cpp b/source/source_md/run_md.cpp index bd39ffc6cc2..3a5ffe9f19a 100644 --- a/source/source_md/run_md.cpp +++ b/source/source_md/run_md.cpp @@ -56,8 +56,8 @@ void md_line(UnitCell& unit_in, ModuleESolver::ESolver* p_esolver, const Paramet } else { - // mohan add 2026-01-04 - const int stress_step = 0; + // mohan add 2026-01-04 + const int stress_step = 0; const int force_step = 0; const int istep_print = mdrun->step_ + mdrun->step_rst_ + 1; ModuleIO::print_screen(stress_step, force_step, istep_print); From 39811c49b0a2cacfcc3fd341ce4ac6179c858ac5 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 05:50:37 +0800 Subject: [PATCH 09/13] refactor(source_io): replace std::exception with WARNING_QUIT Replace standard exception handling with project-specific error handling in source_io directory to comply with cpp-code-style skill guidelines. Changes: - Replace all instances of throw with ModuleBase::WARNING_QUIT - throw std::runtime_error -> WARNING_QUIT - throw std::logic_error -> WARNING_QUIT - throw std::invalid_argument -> WARNING_QUIT - throw std::domain_error -> WARNING_QUIT - Remove unnecessary #include - Add #include "source_base/tool_quit.h" where needed Files modified: - module_restart/restart.cpp (4 instances) - module_chgpot/write_libxc_r.cpp (9 instances) - module_wannier/to_wannier90_lcao.h (1 instance) - module_wannier/to_wannier90_lcao_in_pw.h (1 instance) - module_wannier/to_wannier90_pw.h (1 instance) - module_wannier/to_wannier90.cpp (1 instance) - module_unk/berryphase.h (1 instance) - module_parameter/read_input_tool.h (1 instance) - module_parameter/input_conv.cpp (1 instance) This follows the ABACUS code style rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions. --- source/source_io/module_parameter/input_conv.cpp | 3 ++- source/source_io/module_parameter/read_input_tool.h | 4 ++-- source/source_io/module_unk/berryphase.h | 3 ++- source/source_io/module_wannier/to_wannier90.cpp | 4 ++-- source/source_io/module_wannier/to_wannier90_lcao.h | 3 ++- source/source_io/module_wannier/to_wannier90_lcao_in_pw.h | 3 ++- source/source_io/module_wannier/to_wannier90_pw.h | 3 ++- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/source/source_io/module_parameter/input_conv.cpp b/source/source_io/module_parameter/input_conv.cpp index c83b46ecd6e..43ab05f3c84 100644 --- a/source/source_io/module_parameter/input_conv.cpp +++ b/source/source_io/module_parameter/input_conv.cpp @@ -2,6 +2,7 @@ #include "source_base/global_function.h" #include "source_base/global_variable.h" +#include "source_base/tool_quit.h" #include "source_cell/module_symmetry/symmetry.h" #include "source_cell/unitcell.h" #include "source_estate/occupy.h" @@ -398,7 +399,7 @@ void Input_Conv::Convert() } else { - throw std::invalid_argument(std::string(__FILE__)+" line "+std::to_string(__LINE__)); + ModuleBase::WARNING_QUIT("input_conv", "Invalid exx_hybrid_alpha type"); } } if(!erfc_alpha.empty()) diff --git a/source/source_io/module_parameter/read_input_tool.h b/source/source_io/module_parameter/read_input_tool.h index d37967742f6..4de34a3dc4a 100644 --- a/source/source_io/module_parameter/read_input_tool.h +++ b/source/source_io/module_parameter/read_input_tool.h @@ -1,9 +1,9 @@ #include #include -#include #ifdef __MPI #include "source_base/parallel_common.h" #endif +#include "source_base/tool_quit.h" #define strvalue item.str_values[0] #define intvalue std::stoi(item.str_values[0]) @@ -200,7 +200,7 @@ void parse_expression(const std::vector& expressions, std::vector& psi, const Parallel_Orbitals* pv) { - throw std::logic_error("The wave function of toWannier90_LCAO_IN_PW is generally a std::complex type."); + ModuleBase::WARNING_QUIT("toWannier90_LCAO", "The wave function of toWannier90_LCAO is generally a std::complex type."); } void cal_Amn(const UnitCell& ucell, const K_Vectors& kv, const psi::Psi>& psi); diff --git a/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h b/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h index 763c050a81b..17c1e4789b9 100644 --- a/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h +++ b/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h @@ -9,6 +9,7 @@ #include "source_base/matrix3.h" #include "source_base/parallel_reduce.h" #include "source_base/timer.h" +#include "source_base/tool_quit.h" #include "source_base/vector3.h" #include "source_base/ylm.h" #include "source_basis/module_ao/ORB_atomic_lm.h" @@ -61,7 +62,7 @@ class toWannier90_LCAO_IN_PW : public toWannier90_PW const psi::Psi* psi, const Parallel_Orbitals* pv) { - throw std::logic_error("The wave function of toWannier90_LCAO_IN_PW is generally a std::complex type."); + ModuleBase::WARNING_QUIT("toWannier90_LCAO_IN_PW", "The wave function of toWannier90_LCAO_IN_PW is generally a std::complex type."); } protected: diff --git a/source/source_io/module_wannier/to_wannier90_pw.h b/source/source_io/module_wannier/to_wannier90_pw.h index 757948b2073..5210075400e 100644 --- a/source/source_io/module_wannier/to_wannier90_pw.h +++ b/source/source_io/module_wannier/to_wannier90_pw.h @@ -13,6 +13,7 @@ #include "source_base/global_function.h" #include "source_base/global_variable.h" #include "source_base/matrix.h" +#include "source_base/tool_quit.h" #include "source_base/matrix3.h" #include "source_cell/klist.h" #include "source_lcao/wavefunc_in_pw.h" @@ -50,7 +51,7 @@ class toWannier90_PW : public toWannier90 const psi::Psi* psi ) { - throw std::logic_error("The wave function of toWannier90_PW is generally a std::complex type."); + ModuleBase::WARNING_QUIT("toWannier90_PW", "The wave function of toWannier90_PW is generally a std::complex type."); } void cal_Amn(const psi::Psi>& psi_pw, const ModulePW::PW_Basis_K* wfcpw); From 25528eb48ed9bb5c7da81ae60428488f1cdbe12c Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 21:37:18 +0800 Subject: [PATCH 10/13] =?UTF-8?q?revert(vector3):=20=E6=92=A4=E9=94=80oper?= =?UTF-8?q?ator=3D=3D=E7=9A=84eps=E7=B2=BE=E5=BA=A6=E6=AF=94=E8=BE=83?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 恢复Vector3的operator==为直接比较 - 移除之前添加的eps精度比较逻辑 修改文件: - source/source_base/vector3.h --- source/source_base/vector3.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/source_base/vector3.h b/source/source_base/vector3.h index 6d0281038f9..39cdbeb014c 100644 --- a/source/source_base/vector3.h +++ b/source/source_base/vector3.h @@ -389,8 +389,7 @@ template inline bool operator!=(const Vector3 &u, const Vector3 // whether u == v template inline bool operator==(const Vector3 &u, const Vector3 &v) { - const T eps = 1e-15; - if (std::abs(u.x - v.x) < eps && std::abs(u.y - v.y) < eps && std::abs(u.z - v.z) < eps) + if (u.x == v.x && u.y == v.y && u.z == v.z) return true; return false; } From 5be25fbd45fb8ed31336051905b3aba461c975d8 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 21:41:46 +0800 Subject: [PATCH 11/13] Revert "refactor(source_io): replace std::exception with WARNING_QUIT" This reverts commit 39811c49b0a2cacfcc3fd341ce4ac6179c858ac5. --- source/source_io/module_parameter/input_conv.cpp | 3 +-- source/source_io/module_parameter/read_input_tool.h | 4 ++-- source/source_io/module_unk/berryphase.h | 3 +-- source/source_io/module_wannier/to_wannier90.cpp | 4 ++-- source/source_io/module_wannier/to_wannier90_lcao.h | 3 +-- source/source_io/module_wannier/to_wannier90_lcao_in_pw.h | 3 +-- source/source_io/module_wannier/to_wannier90_pw.h | 3 +-- 7 files changed, 9 insertions(+), 14 deletions(-) diff --git a/source/source_io/module_parameter/input_conv.cpp b/source/source_io/module_parameter/input_conv.cpp index 43ab05f3c84..c83b46ecd6e 100644 --- a/source/source_io/module_parameter/input_conv.cpp +++ b/source/source_io/module_parameter/input_conv.cpp @@ -2,7 +2,6 @@ #include "source_base/global_function.h" #include "source_base/global_variable.h" -#include "source_base/tool_quit.h" #include "source_cell/module_symmetry/symmetry.h" #include "source_cell/unitcell.h" #include "source_estate/occupy.h" @@ -399,7 +398,7 @@ void Input_Conv::Convert() } else { - ModuleBase::WARNING_QUIT("input_conv", "Invalid exx_hybrid_alpha type"); + throw std::invalid_argument(std::string(__FILE__)+" line "+std::to_string(__LINE__)); } } if(!erfc_alpha.empty()) diff --git a/source/source_io/module_parameter/read_input_tool.h b/source/source_io/module_parameter/read_input_tool.h index 4de34a3dc4a..d37967742f6 100644 --- a/source/source_io/module_parameter/read_input_tool.h +++ b/source/source_io/module_parameter/read_input_tool.h @@ -1,9 +1,9 @@ #include #include +#include #ifdef __MPI #include "source_base/parallel_common.h" #endif -#include "source_base/tool_quit.h" #define strvalue item.str_values[0] #define intvalue std::stoi(item.str_values[0]) @@ -200,7 +200,7 @@ void parse_expression(const std::vector& expressions, std::vector& psi, const Parallel_Orbitals* pv) { - ModuleBase::WARNING_QUIT("toWannier90_LCAO", "The wave function of toWannier90_LCAO is generally a std::complex type."); + throw std::logic_error("The wave function of toWannier90_LCAO_IN_PW is generally a std::complex type."); } void cal_Amn(const UnitCell& ucell, const K_Vectors& kv, const psi::Psi>& psi); diff --git a/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h b/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h index 17c1e4789b9..763c050a81b 100644 --- a/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h +++ b/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h @@ -9,7 +9,6 @@ #include "source_base/matrix3.h" #include "source_base/parallel_reduce.h" #include "source_base/timer.h" -#include "source_base/tool_quit.h" #include "source_base/vector3.h" #include "source_base/ylm.h" #include "source_basis/module_ao/ORB_atomic_lm.h" @@ -62,7 +61,7 @@ class toWannier90_LCAO_IN_PW : public toWannier90_PW const psi::Psi* psi, const Parallel_Orbitals* pv) { - ModuleBase::WARNING_QUIT("toWannier90_LCAO_IN_PW", "The wave function of toWannier90_LCAO_IN_PW is generally a std::complex type."); + throw std::logic_error("The wave function of toWannier90_LCAO_IN_PW is generally a std::complex type."); } protected: diff --git a/source/source_io/module_wannier/to_wannier90_pw.h b/source/source_io/module_wannier/to_wannier90_pw.h index 5210075400e..757948b2073 100644 --- a/source/source_io/module_wannier/to_wannier90_pw.h +++ b/source/source_io/module_wannier/to_wannier90_pw.h @@ -13,7 +13,6 @@ #include "source_base/global_function.h" #include "source_base/global_variable.h" #include "source_base/matrix.h" -#include "source_base/tool_quit.h" #include "source_base/matrix3.h" #include "source_cell/klist.h" #include "source_lcao/wavefunc_in_pw.h" @@ -51,7 +50,7 @@ class toWannier90_PW : public toWannier90 const psi::Psi* psi ) { - ModuleBase::WARNING_QUIT("toWannier90_PW", "The wave function of toWannier90_PW is generally a std::complex type."); + throw std::logic_error("The wave function of toWannier90_PW is generally a std::complex type."); } void cal_Amn(const psi::Psi>& psi_pw, const ModulePW::PW_Basis_K* wfcpw); From 56beae8966c8bdb99e16fddebbc8dde154e970dd Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 21:54:09 +0800 Subject: [PATCH 12/13] Revert "refactor(write_libxc_r): replace std::exception with WARNING_QUIT" This reverts commit f0558c56b27ae4818c2fed9f52c9073c2f1c088c. --- .../source_io/module_chgpot/write_libxc_r.cpp | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/source/source_io/module_chgpot/write_libxc_r.cpp b/source/source_io/module_chgpot/write_libxc_r.cpp index 21df763f728..e2a246bacf8 100644 --- a/source/source_io/module_chgpot/write_libxc_r.cpp +++ b/source/source_io/module_chgpot/write_libxc_r.cpp @@ -20,8 +20,8 @@ #include #include #include +#include #include -#include "source_base/tool_quit.h" void ModuleIO::write_libxc_r( const int order, @@ -116,7 +116,10 @@ void ModuleIO::write_libxc_r( case 1: vrho .resize( nrxx * nspin ); case 0: exc .resize( nrxx ); break; - default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported (must be 0-4)"); + default: throw std::domain_error( + "order =" + std::to_string(order) + + " unfinished in " + std::string(__FILE__) + + " line " + std::to_string(__LINE__)); break; } if(is_gga) @@ -134,7 +137,10 @@ void ModuleIO::write_libxc_r( v2sigma2 .resize( nrxx * ((1==nspin)?1:6) ); case 1: vsigma .resize( nrxx * ((1==nspin)?1:3) ); case 0: break; - default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported for GGA (must be 0-4)"); + default: throw std::domain_error( + "order =" + std::to_string(order) + + " unfinished in " + std::string(__FILE__) + + " line " + std::to_string(__LINE__)); break; } } @@ -167,8 +173,11 @@ void ModuleIO::write_libxc_r( break; case 0: xc_lda_exc ( &func, nrxx, rho.data(), exc.data() ); break; - default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported for LDA (must be 0-4)"); - break; + default: throw std::domain_error( + "order =" + std::to_string(order) + + " unfinished in " + std::string(__FILE__) + + " line " + std::to_string(__LINE__)); + break; } break; } @@ -196,14 +205,21 @@ void ModuleIO::write_libxc_r( break; case 0: xc_gga_exc ( &func, nrxx, rho.data(), sigma.data(), exc.data() ); break; - default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported for GGA (must be 0-4)"); + default: throw std::domain_error( + "order =" + std::to_string(order) + + " unfinished in " + std::string(__FILE__) + + " line " + std::to_string(__LINE__)); break; } break; } default: - ModuleBase::WARNING_QUIT("write_libxc_r", "func.info->family =" + std::to_string(func.info->family) + " not supported"); - break; + { + throw std::domain_error( + "func.info->family =" + std::to_string(func.info->family) + + " unfinished in " + std::string(__FILE__) + + " line " + std::to_string(__LINE__)); + break; } } // end switch( func.info->family ) } // end for( xc_func_type &func : funcs ) @@ -242,7 +258,11 @@ void ModuleIO::write_libxc_r( pw_rhod.nz); #else if(nspin!=1) - { ModuleBase::WARNING_QUIT("write_libxc_r", "nspin=" + std::to_string(nspin) + " is invalid for ModuleIO::write_cube_core without MPI"); + { throw std::invalid_argument( + "nspin=" + std::to_string(nspin) + + " is invalid for ModuleIO::write_cube_core without MPI. see " + + std::string(__FILE__) + " line " + + std::to_string(__LINE__)); } ModuleIO::write_cube_core( ofs, @@ -274,7 +294,10 @@ void ModuleIO::write_libxc_r( case 1: write_data( "vrho" , vrho , nspin ); case 0: write_data( "exc" , exc , 1 ); break; - default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported (must be 0-4)"); + default: throw std::domain_error( + "order =" + std::to_string(order) + + " unfinished in " + std::string(__FILE__) + + " line " + std::to_string(__LINE__)); break; } if(is_gga) @@ -292,7 +315,10 @@ void ModuleIO::write_libxc_r( write_data( "v2sigma2" , v2sigma2 , (1==nspin)?1:6 ); case 1: write_data( "vsigma" , vsigma , (1==nspin)?1:3 ); case 0: break; - default: ModuleBase::WARNING_QUIT("write_libxc_r", "order =" + std::to_string(order) + " not supported for GGA (must be 0-4)"); + default: throw std::domain_error( + "order =" + std::to_string(order) + + " unfinished in " + std::string(__FILE__) + + " line " + std::to_string(__LINE__)); break; } } From ca2838d76adcf66347397d3047ec62be459b0f14 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 8 Mar 2026 21:54:16 +0800 Subject: [PATCH 13/13] Revert "refactor(restart): replace std::runtime_error with WARNING_QUIT" This reverts commit 5682e00cda28685ae6253e2bd41a72c776e84f57. --- source/source_io/module_restart/restart.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/source_io/module_restart/restart.cpp b/source/source_io/module_restart/restart.cpp index cee2d954ac6..c960215a2a6 100644 --- a/source/source_io/module_restart/restart.cpp +++ b/source/source_io/module_restart/restart.cpp @@ -4,9 +4,9 @@ #include #include +#include #include "source_base/global_function.h" -#include "source_base/tool_quit.h" void Restart::write_file1(const std::string &file_name, const void*const ptr, const size_t size) const { @@ -25,7 +25,7 @@ bool Restart::write_file2(const std::string& file_name, const void* const ptr, c const int file = open(file_name.c_str(), O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR); if (-1 == file){ if (error_quit){ - ModuleBase::WARNING_QUIT("Restart::write_file2", "can't open restart save file. errno=" + ModuleBase::GlobalFunc::TO_STRING(errno)); + throw std::runtime_error("can't open restart save file. \nerrno=" + ModuleBase::GlobalFunc::TO_STRING(errno) + ".\n" + std::string(__FILE__) + " line " + std::to_string(__LINE__)); } else { return false; } @@ -33,7 +33,7 @@ bool Restart::write_file2(const std::string& file_name, const void* const ptr, c auto error = write(file, ptr, size); if (-1 == error) { if (error_quit) { - ModuleBase::WARNING_QUIT("Restart::write_file2", "can't write restart save file. errno=" + ModuleBase::GlobalFunc::TO_STRING(errno)); + throw std::runtime_error("can't write restart save file. \nerrno=" + ModuleBase::GlobalFunc::TO_STRING(errno) + ".\n" + std::string(__FILE__) + " line " + std::to_string(__LINE__)); } else { return false; } @@ -52,7 +52,7 @@ bool Restart::read_file2(const std::string& file_name, void* const ptr, const si const int file = open(file_name.c_str(), O_RDONLY); if (-1 == file) { if (error_quit) { - ModuleBase::WARNING_QUIT("Restart::read_file2", "can't open restart load file. errno=" + ModuleBase::GlobalFunc::TO_STRING(errno)); + throw std::runtime_error("can't open restart load file. \nerrno=" + ModuleBase::GlobalFunc::TO_STRING(errno) + ".\n" + std::string(__FILE__) + " line " + std::to_string(__LINE__)); } else { return false; } @@ -60,11 +60,11 @@ bool Restart::read_file2(const std::string& file_name, void* const ptr, const si auto error = read(file, ptr, size); if (-1 == error) { if (error_quit) { - ModuleBase::WARNING_QUIT("Restart::read_file2", "can't read restart load file. errno=" + ModuleBase::GlobalFunc::TO_STRING(errno)); + throw std::runtime_error("can't read restart load file. \nerrno=" + ModuleBase::GlobalFunc::TO_STRING(errno) + ".\n" + std::string(__FILE__) + " line " + std::to_string(__LINE__)); } else { return false; } } close(file); return true; -} +} \ No newline at end of file