Skip to content

Commit 03a0d43

Browse files
authored
Merge branch 'develop' into doc
2 parents d51b63a + 6d1d4fa commit 03a0d43

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

source/source_io/module_parameter/read_input.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <array>
1010
#include <vector>
1111
#include <cassert>
12+
#include <cctype>
1213
#include <limits>
1314
#include "source_base/formatter.h"
1415
#include "source_base/global_file.h"
@@ -522,32 +523,32 @@ void ReadInput::check_ntype(const std::string& fn, int& param_ntype)
522523
{
523524
break;
524525
}
525-
else if (isalpha(temp[0]))
526+
else if (!temp.empty() && std::isalpha(static_cast<unsigned char>(temp[0])))
526527
{
527528
ntype_stru += 1;
528529
}
529530
}
530531
}
531532

532-
if (param_ntype == 0)
533+
if (ntype_stru <= 0)
533534
{
534-
param_ntype = ntype_stru;
535-
GlobalV::ofs_running << " 'ntype' is no longer required in INPUT, and "
536-
"it will be ignored. "
537-
<< std::endl;
535+
ModuleBase::WARNING_QUIT("ReadInput::check_ntype",
536+
"Failed to detect valid ntype from STRU: no valid ATOMIC_SPECIES entries were found.");
538537
}
539-
else if (param_ntype != ntype_stru)
538+
539+
if (param_ntype < 0)
540540
{
541-
ModuleBase::WARNING_QUIT("ReadInput",
542-
"The ntype in INPUT is not equal to the ntype "
543-
"counted in STRU, check it.");
541+
ModuleBase::WARNING_QUIT("ReadInput::check_ntype", "The ntype in INPUT should not be less than 0.");
544542
}
545-
if (param_ntype <= 0)
543+
else if (param_ntype != 0 && param_ntype != ntype_stru)
546544
{
547-
ModuleBase::WARNING_QUIT("ReadInput", "ntype should be greater than 0.");
545+
ModuleBase::WARNING_QUIT("ReadInput::check_ntype",
546+
"The ntype in INPUT is not equal to the ntype "
547+
"counted in STRU, check it.");
548548
}
549-
else
549+
else if (param_ntype == 0)
550550
{
551+
param_ntype = ntype_stru;
551552
GlobalV::ofs_running << " 'ntype' is automatically set to " << param_ntype << std::endl;
552553
}
553554
}

0 commit comments

Comments
 (0)