forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool_check.cpp
More file actions
90 lines (84 loc) · 1.85 KB
/
tool_check.cpp
File metadata and controls
90 lines (84 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "tool_check.h"
#include "tool_quit.h"
namespace ModuleBase
{
void CHECK_NAME(std::ifstream &ifs,const std::string &name_in,bool quit)
{
std::string name;
ifs >> name;
if ( name != name_in)
{
if(quit)
{
//GlobalV::ofs_warning << "\n name = " <<name;
//GlobalV::ofs_warning << "\n should be = " << name_in;
std::cout << "\n name = " <<name;
std::cout << "\n should be = " << name_in;
WARNING_QUIT("CHECK_NAME","Some parameter name is wrong!");
}
else
{
std::cout <<"\n Can not match : "<<name<<"(readin) "<<name_in<<std::endl;
}
}
return;
}
void CHECK_INT(std::ifstream &ifs,const int &v,bool quit)
{
int v_in;
ifs >> v_in;
if( v!= v_in)
{
if(quit)
{
std::cout << "\n value = " << v_in;
std::cout << "\n should be = " << v;
WARNING_QUIT("CHECK_INT","Some parameter name is wrong!");
}
else
{
std::cout <<"\n Can not match well: "<<v_in<<"(readin) "<<v<<std::endl;
}
}
return;
}
void CHECK_DOUBLE(std::ifstream &ifs,const double &v,bool quit)
{
const double tiny = 1.0e-5;
double v_in;
ifs >> v_in;
if( fabs(v - v_in) > tiny )
{
if(quit)
{
std::cout << " read in value = " << v_in << std::endl;
std::cout << " the value should be = " << v << std::endl;
WARNING_QUIT("CHECK_DOUBLE","the name of parameter wrong!");
}
else
{
std::cout <<" can not match well (1.0e-5): "<< v_in <<"(readin) "<<v<<std::endl;
}
}
return;
}
void CHECK_STRING(std::ifstream &ifs,const std::string &v,bool quit)
{
std::string v_in;
ifs >> v_in;
if( v_in != v )
{
if(quit)
{
std::cout << " read in value = " << v_in << std::endl;
std::cout << " the value should be = " << v << std::endl;
WARNING_QUIT("CHECK_STRING","the name of parameter wrong!");
}
else
{
std::cout <<" can not match well : "<<v_in<<"(readin) "<<v<<std::endl;
}
}
return;
}
}