@@ -40,18 +40,18 @@ void ReadInput::item_output()
4040 item.annotation = " > 0 output charge density for selected electron steps"
4141 " , second parameter controls the precision, default is 3." ;
4242 item.read_value = [](const Input_Item& item, Parameter& para) {
43- size_t count = item.get_size ();
44- std::vector< int > out_chg (count); // create a placeholder vector
45- std::transform (item. str_values . begin (), item. str_values . end (), out_chg. begin (), [](std::string s) {
46- return std::stoi (s );
47- });
48- // assign non-negative values to para.input.out_chg
49- std::copy (out_chg. begin (), out_chg. end (), para.input .out_chg . begin ()) ;
43+ const size_t count = item.get_size ();
44+ if (count != 1 && count != 2 )
45+ {
46+ ModuleBase::WARNING_QUIT ( " ReadInput " , " out_chg should have 1 or 2 values " );
47+ }
48+ para.input .out_chg [ 0 ] = assume_as_boolean (item. str_values [ 0 ]);
49+ para.input .out_chg [ 1 ] = (count == 2 ) ? std::stoi (item. str_values [ 1 ]) : 3 ;
5050 };
5151 item.reset_value = [](const Input_Item& item, Parameter& para) {
5252 para.input .out_chg [0 ] = (para.input .calculation == " get_wf" || para.input .calculation == " get_pchg" )
53- ? 1
54- : para.input .out_chg [0 ];
53+ ? 1
54+ : para.input .out_chg [0 ];
5555 };
5656 sync_intvec (input.out_chg , 2 , 0 );
5757 this ->add_item (item);
0 commit comments