Skip to content

Commit 3982338

Browse files
committed
Add a warning_quit in DeePKS.
1 parent 4763683 commit 3982338

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

source/source_lcao/module_deepks/deepks_basic.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ void DeePKS_domain::load_model(const std::string& model_file, torch::jit::script
6161
ModuleBase::TITLE("DeePKS_domain", "load_model");
6262
ModuleBase::timer::tick("DeePKS_domain", "load_model");
6363

64+
// check whether file exists
65+
std::ifstream ifs(model_file.c_str());
66+
if (!ifs)
67+
{
68+
ModuleBase::timer::tick("DeePKS_domain", "load_model");
69+
ModuleBase::WARNING_QUIT("DeePKS_domain::load_model", "No model file named " + model_file + ", please check!");
70+
return;
71+
}
72+
ifs.close();
6473
try
6574
{
6675
model = torch::jit::load(model_file);

0 commit comments

Comments
 (0)