Skip to content

Commit 870c816

Browse files
authored
Revert "The old and new programmes of reading INPUT coexist now."
1 parent a0c3ece commit 870c816

File tree

10 files changed

+33
-64
lines changed

10 files changed

+33
-64
lines changed

source/driver.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
#include "src_io/print_info.h"
1313
#include "module_base/timer.h"
1414

15-
#include "src_io/read_txt_input_list.h"
16-
#include "src_io/read_txt_input_process.h"
17-
1815
Driver::Driver(){}
1916

2017

@@ -80,11 +77,6 @@ void Driver::reading(void)
8077
INPUT.Print( ss1.str() );
8178
//ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running,"READING CARDS");
8279

83-
Read_Txt_Input::Input_List input_list;
84-
input_list.set_items();
85-
Read_Txt_Input::Input_Process input_process(input_list);
86-
input_process.read_and_convert(GlobalV::global_in_card);
87-
8880
ModuleBase::timer::tick("Driver","reading");
8981
return;
9082
}

source/input.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ void Input::Default(void)
219219
//----------------------------------------------------------
220220
// iteration
221221
//----------------------------------------------------------
222+
dr2 = 1.0e-9;
222223
niter = 40;
223224
this->nstep = 0;
224225
out_stru = 0;
@@ -943,6 +944,10 @@ bool Input::Read(const std::string &fn)
943944
//----------------------------------------------------------
944945
// iteration
945946
//----------------------------------------------------------
947+
else if (strcmp("dr2", word) == 0)
948+
{
949+
read_value(ifs, dr2);
950+
}
946951
else if (strcmp("niter", word) == 0)
947952
{
948953
read_value(ifs, niter);
@@ -1855,8 +1860,7 @@ bool Input::Read(const std::string &fn)
18551860
//xiaohui add 2015-09-15
18561861
if(word[0] != '#' && word[0] != '/')
18571862
{
1858-
// Peize Lin delete 2022.01.06 temporarily
1859-
//input_error = 1;
1863+
input_error = 1;
18601864
std::cout<<" THE PARAMETER NAME '" << word << "' IS NOT USED!" << std::endl;
18611865
}
18621866
// mohan screen this 2012-06-30
@@ -2308,6 +2312,7 @@ void Input::Bcast()
23082312
Parallel_Common::bcast_int( test_force );
23092313
Parallel_Common::bcast_int( test_stress );
23102314

2315+
Parallel_Common::bcast_double( dr2 );
23112316
Parallel_Common::bcast_int( niter );
23122317
Parallel_Common::bcast_int( this->nstep );
23132318
Parallel_Common::bcast_int( out_stru ); //mohan add 2012-03-23

source/input.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class Input
179179
//==========================================================
180180
// iteration
181181
//==========================================================
182+
double dr2; // \sum |rhog_out - rhog_in |^2
182183
int niter; // number of max elec iter
183184
int nstep; // number of max ionic iter
184185
int out_stru; // outut stru file each ion step

source/input_conv.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ void Input_Conv::Convert(void)
193193
GlobalV::TEST_FORCE = INPUT.test_force;
194194
GlobalV::TEST_STRESS = INPUT.test_stress;
195195

196+
//----------------------------------------------------------
197+
// iteration (1/3)
198+
//----------------------------------------------------------
199+
GlobalV::DRHO2 = INPUT.dr2;
200+
196201
//----------------------------------------------------------
197202
// wavefunction / charge / potential / (2/4)
198203
//----------------------------------------------------------

source/src_io/read_txt_input-general.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Read_Txt_Input
1818
{
1919
this->output_labels.push_back("Parameters (1.General)");
2020

21-
/*{ // LDA ; LSDA ; non-linear spin
21+
{
2222
Input_Item item("nspin");
2323
item.default_1(1);
2424
item.annotation = "1: single spin; 2: up and down spin; 4: noncollinear spin";
@@ -32,9 +32,9 @@ namespace Read_Txt_Input
3232
GlobalV::NSPIN = self.values[0].geti();
3333
};
3434
this->add_item(item);
35-
}*/
35+
}
3636

37-
/*{ // number of atom types
37+
{
3838
Input_Item item("ntype");
3939
item.default_1(0);
4040
item.annotation = "atom species number";
@@ -48,9 +48,9 @@ namespace Read_Txt_Input
4848
GlobalC::ucell.ntype = self.values[0].geti();
4949
};
5050
this->add_item(item);
51-
}*/
51+
}
5252

53-
/*{ // turn on symmetry or not
53+
{
5454
Input_Item item("symmetry");
5555
item.default_1(false);
5656
item.annotation = "turn symmetry on or off";
@@ -59,6 +59,6 @@ namespace Read_Txt_Input
5959
ModuleSymmetry::Symmetry::symm_flag = self.values[0].getb();
6060
};
6161
this->add_item(item);
62-
}*/
62+
}
6363
}
6464
}

source/src_io/read_txt_input-pw.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Read_Txt_Input
1717
{
1818
this->output_labels.push_back("Parameters (2.Pw)");
1919

20-
/*{
20+
{
2121
Input_Item item("ecutwfc");
2222
item.default_1(100.0,"Ry");
2323
item.check_values_size(1,2);
@@ -39,22 +39,6 @@ namespace Read_Txt_Input
3939
// ?? GlobalC::pw.set()
4040
};
4141
this->add_item(item);
42-
}*/
43-
44-
{ // \sum |rhog_out - rhog_in |^2
45-
Input_Item item("dr2");
46-
item.default_1(1.0e-9);
47-
item.annotation = "charge density error";
48-
item.check_transform = [](Input_Item &self)
49-
{
50-
if(self.values[0].getd()<=0)
51-
throw std::invalid_argument("dr2 must > 0");
52-
};
53-
item.convert = [](const Input_Item &self)
54-
{
55-
GlobalV::DRHO2 = self.values[0].getd();
56-
};
57-
this->add_item(item);
5842
}
5943
}
6044
}

source/src_io/read_txt_input-spectrum.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Read_Txt_Input
1313
{
1414
this->output_labels.push_back("Parameters (15.Spectrum)");
1515

16-
/*{
16+
{
1717
Input_Item item("ocp_set");
1818
item.annotation = "set occupation number";
1919
item.check_values_size(0, std::numeric_limits<int>::max());
@@ -22,6 +22,6 @@ namespace Read_Txt_Input
2222
// ...
2323
};
2424
this->add_item(item);
25-
}*/
25+
}
2626
}
2727
}

source/src_io/read_txt_input_list.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
//=======================
55

66
#include "read_txt_input_list.h"
7-
#include "module_base/tool_title.h"
87

98
namespace Read_Txt_Input
109
{
1110
void Input_List::add_item(const Input_Item &input_item)
1211
{
13-
this->list.insert(make_pair(input_item.label, input_item));
14-
this->output_labels.push_back(input_item.label);
12+
list.insert(make_pair(input_item.label, input_item));
13+
output_labels.push_back(input_item.label);
1514
}
1615

1716
/*
@@ -34,10 +33,9 @@ namespace Read_Txt_Input
3433

3534
void Input_List::set_items()
3635
{
37-
ModuleBase::TITLE("Input_List","set_items");
38-
this->set_items_general();
39-
this->set_items_pw();
40-
this->set_items_spectrum();
36+
set_items_general();
37+
set_items_pw();
38+
set_items_spectrum();
4139
}
4240

4341
}

source/src_io/read_txt_input_process.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "src_io/read_txt_tools.h"
99
#include "module_base/global_variable.h"
10-
#include "module_base/tool_title.h"
1110

1211
#ifdef USE_CEREAL_SERIALIZATION
1312
#include "src_lcao/serialization_cereal.h"
@@ -17,36 +16,26 @@ namespace Read_Txt_Input
1716
{
1817
void Input_Process::read_and_convert(const std::string &file_name)
1918
{
20-
ModuleBase::TITLE("Input_Process","read_and_convert");
2119
if(GlobalV::MY_RANK==0)
2220
{
2321
this->read(file_name);
2422
this->check_transform();
2523
this->default_2();
26-
// Peize Lin delete 2022.01.06 temporarily
27-
//this->out(GlobalV::global_out_dir + file_name);
24+
this->out(GlobalV::global_out_dir + file_name);
2825
}
2926
this->bcast();
30-
// Peize Lin add 2022.01.06 temporarily
31-
this->out(GlobalV::global_out_dir + file_name + "-new-"+std::to_string(GlobalV::MY_RANK));
3227
this->convert();
3328
}
3429

3530
void Input_Process::read(const std::string &file_name)
3631
{
37-
ModuleBase::TITLE("Input_Process","read");
3832
const std::map<std::string, std::vector<std::string>> inputs_read
3933
= Read_Txt_Tools::read_file_to_map(file_name, {"#","\\"}, true);
4034
for(const auto & input_read : inputs_read)
4135
{
4236
const auto item_ptr = this->input.list.find(input_read.first);
4337
if(item_ptr==this->input.list.end())
44-
{
45-
// Peize Lin delete interrupt 2022.01.06 temporarily
46-
//throw std::out_of_range("input_read.first");
47-
GlobalV::ofs_warning<<" INPUT-new '" << input_read.first << "' IS NOT USED!" << std::endl;
48-
continue;
49-
}
38+
throw std::out_of_range("input_read.first");
5039
Read_Txt_Input::Input_Item &item = item_ptr->second;
5140

5241
item.values_size_read = input_read.second.size();
@@ -63,7 +52,6 @@ namespace Read_Txt_Input
6352

6453
void Input_Process::check_transform()
6554
{
66-
ModuleBase::TITLE("Input_Process","check_transform");
6755
for(auto &tmp : this->input.list)
6856
{
6957
Read_Txt_Input::Input_Item &item = tmp.second;
@@ -93,15 +81,13 @@ namespace Read_Txt_Input
9381

9482
void Input_Process::default_2()
9583
{
96-
ModuleBase::TITLE("Input_Process","default_2");
9784
for(auto &item : this->input.list)
9885
item.second.default_2(item.second, this->input.list);
9986
this->default_2_global(this->input.list);
10087
}
10188

10289
void Input_Process::out(const std::string &file_name) const
10390
{
104-
ModuleBase::TITLE("Input_Process","out");
10591
std::ofstream ofs(file_name);
10692
for(const std::string &label : this->input.output_labels)
10793
{
@@ -119,9 +105,9 @@ namespace Read_Txt_Input
119105
if(item.values_type[i]=="s")
120106
ofs<<item.values[i].gets()<<" ";
121107
else if(item.values_type[i]=="d")
122-
ofs<<item.values[i].getd()<<" ";
108+
ofs<<std::to_string(item.values[i].getd())<<" ";
123109
else if(item.values_type[i]=="i")
124-
ofs<<item.values[i].geti()<<" ";
110+
ofs<<std::to_string(item.values[i].geti())<<" ";
125111
else if(item.values_type[i]=="b")
126112
{
127113
if(item.values[i].getb())
@@ -139,18 +125,15 @@ namespace Read_Txt_Input
139125

140126
void Input_Process::bcast()
141127
{
142-
ModuleBase::TITLE("Input_Process","bcast");
143128
#ifdef USE_CEREAL_SERIALIZATION
144-
for(auto &item : this->input.list)
145-
ModuleBase::bcast_data_cereal(item.second, MPI_COMM_WORLD, 0);
129+
ModuleBase::bcast_data_cereal(this->input.list, MPI_COMM_WORLD, 0);
146130
#else
147131
#error Input_Process::bcast() needs cereal
148132
#endif
149133
}
150134

151135
void Input_Process::convert()
152136
{
153-
ModuleBase::TITLE("Input_Process","convert");
154137
for(auto &item : this->input.list)
155138
item.second.convert(item.second);
156139
this->convert_global(this->input.list);

source/src_io/write_input.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void Input::Print(const std::string &fn)const
5252
ModuleBase::GlobalFunc::OUTP(ofs,"diago_david_ndim",diago_david_ndim,"max dimension for davidson");
5353
}
5454
ModuleBase::GlobalFunc::OUTP(ofs,"ethr",ethr,"threshold for eigenvalues is cg electron iterations");
55+
ModuleBase::GlobalFunc::OUTP(ofs,"dr2",dr2,"charge density error");
5556
ModuleBase::GlobalFunc::OUTP(ofs,"start_wfc",start_wfc,"start wave functions are from 'atomic' or 'file'");
5657
ModuleBase::GlobalFunc::OUTP(ofs,"start_charge",start_pot,"start charge is from 'atomic' or file");
5758
ModuleBase::GlobalFunc::OUTP(ofs,"charge_extrap",charge_extrap,"atomic; first-order; second-order; dm:coefficients of SIA");

0 commit comments

Comments
 (0)