Skip to content

Commit

Permalink
change error to warning when nspin mismatch in charge reading
Browse files Browse the repository at this point in the history
  • Loading branch information
maki49 committed Nov 29, 2023
1 parent fb1f674 commit b5db28f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions source/module_elecstate/module_charge/charge_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ void Charge::init_rho(elecstate::efermi& eferm_iout, const ModuleBase::ComplexMa
}
else
{
std::cout << "!!! Couldn't find the charge file !!! The default directory \n of SPIN1_CHG.cube is OUT.suffix, "
"or you must set read_file_dir \n to a specific directory. " << std::endl;
read_error = true;
break;
}
Expand Down Expand Up @@ -125,7 +123,15 @@ void Charge::init_rho(elecstate::efermi& eferm_iout, const ModuleBase::ComplexMa
}
}
}
if (read_error) std::cout << "WARNING: Failed to read charge density from file, use atomic initialization instead." << std::endl;
if (read_error)
{
std::cout << " WARNING: Failed to read charge density from file. Possible reasons: " << std::endl;
std::cout << " - not found: The default directory of SPIN1_CHG.cube is OUT.suffix, \n"
"or you must set read_file_dir to a specific directory. " << std::endl;
std::cout << " - parameter mismatch: check the previous warning." << std::endl;
std::cout << " Use atomic initialization instead." << std::endl;
}

if (GlobalV::init_chg != "file" || read_error) // mohan add 2007-10-17
{
this->atomic_rho(GlobalV::NSPIN, GlobalC::ucell.omega, rho, strucFac, GlobalC::ucell);
Expand Down
10 changes: 8 additions & 2 deletions source/module_io/read_cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ bool ModuleIO::read_cube(

if(nspin != 4)
{
ModuleBase::CHECK_INT(ifs, nspin);
}
int v_in;
ifs >> v_in;
if (v_in != nspin)
{
std::cout << " WARNING: nspin mismatch: " << nspin << " in INPUT parameters but " << v_in << " in " << fn << std::endl;
return false;
}
}
else
{
ifs >> prenspin;
Expand Down

0 comments on commit b5db28f

Please sign in to comment.