@@ -102,15 +102,40 @@ OperatorEXX<OperatorLCAO<TK, TR>>::OperatorEXX(HS_Matrix_K<TK>* hsk_in,
102102 if (PARAM.inp .calculation == " nscf" && GlobalC::exx_info.info_global .cal_exx )
103103 { // if nscf, read HexxR first and reallocate hR according to the read-in HexxR
104104 const std::string file_name_exx = PARAM.globalv .global_readin_dir + " HexxR" + std::to_string (GlobalV::MY_RANK);
105- if (GlobalC::exx_info.info_ri .real_number )
105+ bool all_exist = true ;
106+ for (int is=0 ;is<PARAM.inp .nspin ;++is)
107+ {
108+ std::ifstream ifs (file_name_exx + " _" + std::to_string (is) + " .csr" );
109+ if (!ifs) { all_exist = false ; break ; }
110+ }
111+ if (all_exist)
106112 {
107- ModuleIO::read_Hexxs_csr (file_name_exx, GlobalC::ucell, PARAM.inp .nspin , PARAM.globalv .nlocal , *Hexxd);
108- if (this ->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer (*Hexxd, this ->hR ); }
113+ // Read HexxR in CSR format
114+ if (GlobalC::exx_info.info_ri .real_number )
115+ {
116+ ModuleIO::read_Hexxs_csr (file_name_exx, GlobalC::ucell, PARAM.inp .nspin , PARAM.globalv .nlocal , *Hexxd);
117+ if (this ->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer (*Hexxd, this ->hR ); }
118+ }
119+ else
120+ {
121+ ModuleIO::read_Hexxs_csr (file_name_exx, GlobalC::ucell, PARAM.inp .nspin , PARAM.globalv .nlocal , *Hexxc);
122+ if (this ->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer (*Hexxc, this ->hR ); }
123+ }
109124 }
110125 else
111126 {
112- ModuleIO::read_Hexxs_csr (file_name_exx, GlobalC::ucell, PARAM.inp .nspin , PARAM.globalv .nlocal , *Hexxc);
113- if (this ->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer (*Hexxc, this ->hR ); }
127+ // Read HexxR in binary format (old version)
128+ const std::string file_name_exx_cereal = PARAM.globalv .global_readin_dir + " HexxR_" + std::to_string (GlobalV::MY_RANK);
129+ if (GlobalC::exx_info.info_ri .real_number )
130+ {
131+ ModuleIO::read_Hexxs_cereal (file_name_exx_cereal, *Hexxd);
132+ if (this ->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer (*Hexxd, this ->hR ); }
133+ }
134+ else
135+ {
136+ ModuleIO::read_Hexxs_cereal (file_name_exx_cereal, *Hexxc);
137+ if (this ->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer (*Hexxc, this ->hR ); }
138+ }
114139 }
115140 this ->use_cell_nearest = false ;
116141 }
@@ -179,11 +204,32 @@ OperatorEXX<OperatorLCAO<TK, TR>>::OperatorEXX(HS_Matrix_K<TK>* hsk_in,
179204 {
180205 // read in Hexx(R)
181206 const std::string restart_HR_path = GlobalC::restart.folder + " HexxR" + std::to_string (GlobalV::MY_RANK);
182- if (GlobalC::exx_info.info_ri .real_number ) {
183- ModuleIO::read_Hexxs_csr (restart_HR_path, GlobalC::ucell, PARAM.inp .nspin , PARAM.globalv .nlocal , *Hexxd);
207+ bool all_exist = true ;
208+ for (int is = 0 ; is < PARAM.inp .nspin ; ++is)
209+ {
210+ std::ifstream ifs (restart_HR_path + " _" + std::to_string (is) + " .csr" );
211+ if (!ifs) { all_exist = false ; break ; }
212+ }
213+ if (all_exist)
214+ {
215+ // Read HexxR in CSR format
216+ if (GlobalC::exx_info.info_ri .real_number ) {
217+ ModuleIO::read_Hexxs_csr (restart_HR_path, GlobalC::ucell, PARAM.inp .nspin , PARAM.globalv .nlocal , *Hexxd);
218+ }
219+ else {
220+ ModuleIO::read_Hexxs_csr (restart_HR_path, GlobalC::ucell, PARAM.inp .nspin , PARAM.globalv .nlocal , *Hexxc);
221+ }
184222 }
185- else {
186- ModuleIO::read_Hexxs_csr (restart_HR_path, GlobalC::ucell, PARAM.inp .nspin , PARAM.globalv .nlocal , *Hexxc);
223+ else
224+ {
225+ // Read HexxR in binary format (old version)
226+ const std::string restart_HR_path_cereal = GlobalC::restart.folder + " HexxR_" + std::to_string (GlobalV::MY_RANK);
227+ if (GlobalC::exx_info.info_ri .real_number ) {
228+ ModuleIO::read_Hexxs_cereal (restart_HR_path_cereal, *Hexxd);
229+ }
230+ else {
231+ ModuleIO::read_Hexxs_cereal (restart_HR_path_cereal, *Hexxc);
232+ }
187233 }
188234 }
189235
0 commit comments