From 5a5ff7f70576ea09c91e384981b2c715e2dc730b Mon Sep 17 00:00:00 2001 From: Qianrui Liu <76200646+Qianruipku@users.noreply.github.com> Date: Fri, 12 Jul 2024 09:15:31 +0800 Subject: [PATCH] Fix: add warning_quit if some parameter is repeated in INPUT (#4639) * Fix: add warning_quit if some parameters ar iseated in INPUT * delete repeated parameters in INPUT * delete repeated INPUT --- source/module_io/read_input.cpp | 7 ++++++- source/module_io/test/support/INPUT | 1 - tests/integrate/108_PW_RE_PINT_RKS/INPUT | 1 - tests/integrate/601_NO_TDDFT_vel_Si/INPUT | 3 --- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/module_io/read_input.cpp b/source/module_io/read_input.cpp index bc24c41836..ad45783fb2 100644 --- a/source/module_io/read_input.cpp +++ b/source/module_io/read_input.cpp @@ -234,8 +234,13 @@ void ReadInput::read_txt_input(Parameter& param, const std::string& filename) { Input_Item* p_item = &(it->second); this->readvalue_items.push_back(p_item); + if(p_item->is_read()) + { + std::string warningstr = "The parameter " + p_item->label + " has been read twice."; + ModuleBase::WARNING_QUIT("ReadInput", warningstr); + } // qianrui delete '/' 2024-07-10, because path has '/' head. - read_information(ifs, it->second.str_values, "#!"); + read_information(ifs, p_item->str_values, "#!"); } else { diff --git a/source/module_io/test/support/INPUT b/source/module_io/test/support/INPUT index bfd558490b..c9958a5a03 100644 --- a/source/module_io/test/support/INPUT +++ b/source/module_io/test/support/INPUT @@ -18,7 +18,6 @@ nspin 1 #1: single spin; 2: up and down spin; 4: noncol kspacing 0 #unit in 1/bohr, should be > 0, default is 0 which means read KPT file min_dist_coef 0.2 #factor related to the allowed minimum distance between two atoms nbands 8 #number of bands -nbands_sto 256 #number of stochastic bands nbands_istate 5 #number of bands around Fermi level for get_pchg calulation symmetry 1 #the control of symmetry init_vel False #read velocity from STRU or not diff --git a/tests/integrate/108_PW_RE_PINT_RKS/INPUT b/tests/integrate/108_PW_RE_PINT_RKS/INPUT index 754be65b60..7e80d6f83c 100644 --- a/tests/integrate/108_PW_RE_PINT_RKS/INPUT +++ b/tests/integrate/108_PW_RE_PINT_RKS/INPUT @@ -5,7 +5,6 @@ suffix autotest relax_nmax 100 force_thr_ev 0.01 stress_thr 1 -out_stru 1 out_level ie pseudo_rcut 10.0 pseudo_mesh 1 diff --git a/tests/integrate/601_NO_TDDFT_vel_Si/INPUT b/tests/integrate/601_NO_TDDFT_vel_Si/INPUT index 3baf2b0c62..8d4b9ac5d8 100644 --- a/tests/integrate/601_NO_TDDFT_vel_Si/INPUT +++ b/tests/integrate/601_NO_TDDFT_vel_Si/INPUT @@ -9,14 +9,11 @@ scf_nmax 50 scf_thr 1e-6 ks_solver scalapack_gvx -basis_type lcao gamma_only 0 -md_nstep 2 mixing_type broyden mixing_beta 0.7 mixing_gg0 0.0 -scf_thr 1.0e-6 calculation md esolver_type tddft