@@ -261,10 +261,13 @@ void ModuleIO::restart_from_file(const std::string& out_dir, // hard-code the fi
261261 assert (gamma_only || multi_k);
262262 const std::string flowf_prefix = gamma_only ? " WFC_GAMMA" : " WFC_NAO_K" ;
263263 // MPI-related variables init
264- int iproc;
264+ int iproc=0 ;
265+
265266 MPI_Comm_rank (p2d.comm (), &iproc);
266267 // then start
267268 int nbands_ = -1 , nbasis_ = -1 ;
269+
270+ // in LCAO, nks == nkstot
268271 for (int ik = 0 ; ik < nks; ik++)
269272 {
270273 // check existence of file
@@ -280,28 +283,36 @@ void ModuleIO::restart_from_file(const std::string& out_dir, // hard-code the fi
280283 std::vector<double > ekb_;
281284 std::vector<double > occ_;
282285 ModuleBase::Vector3<double > kvec;
283- double wk_;
286+ double wk_ = 0.0 ;
287+
284288 if (iproc == 0 ) // only one rank is needed to read the global lowf, ekb, ...
285289 {
286- int ik_;
290+ int ik_ = 0 ;
287291 read_abacus_lowf (flowf, ik_, kvec, nbands, nbasis, lowf_glb, ekb_, occ_, wk_);
292+
288293 assert (ik_ == ik + 1 ); // check the consistency of ik
289294 assert (nbands == nbands_ || nbands_ == -1 ); // check the consistency of nbands
290295 assert (nbasis == nbasis_ || nbasis_ == -1 ); // check the consistency of nbasis
296+
291297 nbands_ = (nbands_ == -1 ) ? nbands : nbands_;
292298 nbasis_ = (nbasis_ == -1 ) ? nbasis : nbasis_;
299+
293300 ekb.insert (ekb.end (), ekb_.begin (), ekb_.end ());
294301 occ.insert (occ.end (), occ_.begin (), occ_.end ());
295302 wk.push_back (wk_);
296303 kvec_c.push_back (kvec);
297304 }
305+
298306 MPI_Barrier (p2d.comm ()); // wait for finishing the reading task
307+
299308 // scatter the lowf_glb to lowf_loc
300309 Parallel_2D p2d_glb;
301310 Parallel_Common::bcast_int (nbands);
302311 Parallel_Common::bcast_int (nbasis);
312+
303313 p2d_glb.init (nbasis, nbands, std::max (nbasis, nbands), p2d.comm ()); // in the same comm world
304314 lowf_loc_k.resize (p2d.nrow * p2d.ncol );
315+
305316 Cpxgemr2d (nbasis,
306317 nbands,
307318 lowf_glb.data (),
@@ -336,6 +347,8 @@ void ModuleIO::restart_from_file(const std::string& out_dir, // hard-code the fi
336347 Parallel_Common::bcast_double (kvec_c[ik].z );
337348 }
338349}
350+
351+
339352// instantiate the template function
340353template void ModuleIO::restart_from_file (const std::string& out_dir,
341354 const Parallel_2D& p2d,
@@ -347,6 +360,7 @@ template void ModuleIO::restart_from_file(const std::string& out_dir,
347360 std::vector<double >& occ,
348361 std::vector<ModuleBase::Vector3<double >>& kvec_c,
349362 std::vector<double >& wk);
363+
350364template void ModuleIO::restart_from_file (const std::string& out_dir,
351365 const Parallel_2D& p2d,
352366 const int & nks,
@@ -357,6 +371,7 @@ template void ModuleIO::restart_from_file(const std::string& out_dir,
357371 std::vector<double >& occ,
358372 std::vector<ModuleBase::Vector3<double >>& kvec_c,
359373 std::vector<double >& wk);
374+
360375template void ModuleIO::restart_from_file (const std::string& out_dir,
361376 const Parallel_2D& p2d,
362377 const int & nks,
@@ -367,6 +382,7 @@ template void ModuleIO::restart_from_file(const std::string& out_dir,
367382 std::vector<double >& occ,
368383 std::vector<ModuleBase::Vector3<double >>& kvec_c,
369384 std::vector<double >& wk);
385+
370386template void ModuleIO::restart_from_file (const std::string& out_dir,
371387 const Parallel_2D& p2d,
372388 const int & nks,
@@ -434,6 +450,7 @@ void ModuleIO::restart_from_file(const std::string& out_dir, // hard-code the fi
434450 assert (occ.size () == nks * nbands);
435451 assert (lowf.size () == nks * nbands * nbasis);
436452}
453+
437454// instantiate the template function
438455template void ModuleIO::restart_from_file (const std::string& out_dir,
439456 const int & nks,
@@ -444,6 +461,7 @@ template void ModuleIO::restart_from_file(const std::string& out_dir,
444461 std::vector<double >& occ,
445462 std::vector<ModuleBase::Vector3<double >>& kvec_c,
446463 std::vector<double >& wk);
464+
447465template void ModuleIO::restart_from_file (const std::string& out_dir,
448466 const int & nks,
449467 int & nbands,
@@ -453,6 +471,7 @@ template void ModuleIO::restart_from_file(const std::string& out_dir,
453471 std::vector<double >& occ,
454472 std::vector<ModuleBase::Vector3<double >>& kvec_c,
455473 std::vector<double >& wk);
474+
456475template void ModuleIO::restart_from_file (const std::string& out_dir,
457476 const int & nks,
458477 int & nbands,
@@ -462,6 +481,7 @@ template void ModuleIO::restart_from_file(const std::string& out_dir,
462481 std::vector<double >& occ,
463482 std::vector<ModuleBase::Vector3<double >>& kvec_c,
464483 std::vector<double >& wk);
484+
465485template void ModuleIO::restart_from_file (const std::string& out_dir,
466486 const int & nks,
467487 int & nbands,
0 commit comments