@@ -83,7 +83,7 @@ void K_Vectors::set(const UnitCell& ucell,
8383
8484 this ->nspin = (this ->nspin == 4 ) ? 1 : this ->nspin ;
8585
86- bool read_succesfully = this ->read_kpoints (ucell, k_file_name, gamma_only_local_, kspacing, kmesh_type_, koffset);
86+ bool read_succesfully = this ->read_kpoints (ucell, k_file_name, gamma_only_local_, kspacing, kmesh_type_, koffset, ofs );
8787#ifdef __MPI
8888 Parallel_Common::bcast_bool (read_succesfully);
8989#endif
@@ -172,11 +172,11 @@ void K_Vectors::set(const UnitCell& ucell,
172172 nspin_in); // assign k points to several process pools
173173#ifdef __MPI
174174 // distribute K point data to the corresponding process
175- this ->mpi_k ();
175+ this ->mpi_k (ofs );
176176#endif
177177
178178 // set the k vectors for the up and down spin
179- this ->set_kup_and_kdw ();
179+ this ->set_kup_and_kdw (ofs );
180180
181181 // initialize ibz_index
182182 this ->ibz_index .resize (this ->nkstot_full );
@@ -212,7 +212,8 @@ bool K_Vectors::read_kpoints(const UnitCell& ucell,
212212 const bool gamma_only_local,
213213 const double kspacing[3 ],
214214 const std::string& kmesh_type,
215- const double koffset[3 ])
215+ const double koffset[3 ],
216+ std::ofstream& ofs_running)
216217{
217218 ModuleBase::TITLE (" K_Vectors" , " read_kpoints" );
218219 if (GlobalV::MY_RANK != 0 )
@@ -225,7 +226,7 @@ bool K_Vectors::read_kpoints(const UnitCell& ucell,
225226 this ->generate_kfile (ucell, fn, gamma_only_local, kspacing, kmesh_type, koffset);
226227
227228 // 2. Read the KPT file and build the k-point list
228- return this ->parse_kfile (fn);
229+ return this ->parse_kfile (fn, ofs_running );
229230}
230231
231232void K_Vectors::generate_kfile (const UnitCell& ucell,
@@ -279,7 +280,7 @@ void K_Vectors::generate_kfile(const UnitCell& ucell,
279280}
280281
281282// 2. Generate the K-point grid automatically according to the KPT file
282- bool K_Vectors::parse_kfile (const std::string& fn)
283+ bool K_Vectors::parse_kfile (const std::string& fn, std::ofstream& ofs_running )
283284{
284285 // 2.1 read the KPT file
285286 std::ifstream ifk (fn.c_str ());
@@ -346,13 +347,13 @@ bool K_Vectors::parse_kfile(const std::string& fn)
346347 {
347348 is_mp = true ;
348349 k_type = 0 ;
349- ModuleBase::GlobalFunc::OUT (GlobalV:: ofs_running, " Input type of k points" , " Monkhorst-Pack(Gamma)" );
350+ ModuleBase::GlobalFunc::OUT (ofs_running, " Input type of k points" , " Monkhorst-Pack(Gamma)" );
350351 }
351352 else if (kword == " Monkhorst-Pack" || kword == " MP" || kword == " mp" )
352353 {
353354 is_mp = true ;
354355 k_type = 1 ;
355- ModuleBase::GlobalFunc::OUT (GlobalV:: ofs_running, " Input type of k points" , " Monkhorst-Pack" );
356+ ModuleBase::GlobalFunc::OUT (ofs_running, " Input type of k points" , " Monkhorst-Pack" );
356357 }
357358 else
358359 {
@@ -436,7 +437,7 @@ bool K_Vectors::parse_kfile(const std::string& fn)
436437
437438 this ->nkstot_full = this ->nks = this ->nkstot ;
438439
439- ModuleBase::GlobalFunc::OUT (GlobalV:: ofs_running, " nkstot" , nkstot);
440+ ModuleBase::GlobalFunc::OUT (ofs_running, " nkstot" , nkstot);
440441 return true ;
441442} // END SUBROUTINE
442443
@@ -515,7 +516,8 @@ void K_Vectors::interpolate_k_between(std::ifstream& ifk, std::vector<ModuleBase
515516
516517void K_Vectors::update_use_ibz (const int & nkstot_ibz,
517518 const std::vector<ModuleBase::Vector3<double >>& kvec_d_ibz,
518- const std::vector<double >& wk_ibz)
519+ const std::vector<double >& wk_ibz,
520+ std::ofstream& ofs_running)
519521{
520522 if (GlobalV::MY_RANK != 0 ) {
521523 return ;
@@ -526,7 +528,7 @@ void K_Vectors::update_use_ibz(const int& nkstot_ibz,
526528 // update nkstot
527529 this ->nks = this ->nkstot = nkstot_ibz;
528530
529- ModuleBase::GlobalFunc::OUT (GlobalV:: ofs_running, " nkstot now" , nkstot);
531+ ModuleBase::GlobalFunc::OUT (ofs_running, " nkstot now" , nkstot);
530532
531533 this ->kvec_d .resize (this ->nkstot * nspin); // qianrui fix a bug 2021-7-13 for nspin=2 in set_kup_and_kdw()
532534
@@ -547,7 +549,7 @@ void K_Vectors::update_use_ibz(const int& nkstot_ibz,
547549// This routine sets the k vectors for the up and down spin
548550// ----------------------------------------------------------
549551// from set_kup_and_kdw.f90
550- void K_Vectors::set_kup_and_kdw ()
552+ void K_Vectors::set_kup_and_kdw (std::ofstream& ofs_running )
551553{
552554 ModuleBase::TITLE (" K_Vectors" , " setup_kup_and_kdw" );
553555
@@ -583,8 +585,8 @@ void K_Vectors::set_kup_and_kdw()
583585 this ->nks *= 2 ;
584586 this ->nkstot *= 2 ;
585587
586- ModuleBase::GlobalFunc::OUT (GlobalV:: ofs_running, " nks(nspin=2)" , nks);
587- ModuleBase::GlobalFunc::OUT (GlobalV:: ofs_running, " nkstot(nspin=2)" , nkstot);
588+ ModuleBase::GlobalFunc::OUT (ofs_running, " nks(nspin=2)" , nks);
589+ ModuleBase::GlobalFunc::OUT (ofs_running, " nkstot(nspin=2)" , nkstot);
588590 break ;
589591 }
590592
@@ -756,17 +758,17 @@ void K_Vectors::reduce_by_symmetry(const UnitCell& ucell,
756758 // resize the kpoint container according to nkstot_ibz
757759 if (use_symm || this ->get_is_mp ())
758760 {
759- this ->update_use_ibz (nkstot_ibz, kvec_d_ibz, wk_ibz);
761+ this ->update_use_ibz (nkstot_ibz, kvec_d_ibz, wk_ibz, GlobalV::ofs_running );
760762 }
761763
762764 return ;
763765}
764766
765- void K_Vectors::set_after_vc (const int & nspin_in, const ModuleBase::Matrix3& G)
767+ void K_Vectors::set_after_vc (const int & nspin_in, const ModuleBase::Matrix3& G, std::ofstream& ofs_running )
766768{
767- GlobalV:: ofs_running << " \n SETUP K-POINTS" << std::endl;
769+ ofs_running << " \n SETUP K-POINTS" << std::endl;
768770 this ->set_nspin (nspin_in);
769- ModuleBase::GlobalFunc::OUT (GlobalV:: ofs_running, " nspin" , this ->get_nspin ());
771+ ModuleBase::GlobalFunc::OUT (ofs_running, " nspin" , this ->get_nspin ());
770772
771773 // set cartesian k vectors.
772774 this ->kvec_d2c (G);
@@ -783,16 +785,16 @@ void K_Vectors::set_after_vc(const int& nspin_in, const ModuleBase::Matrix3& G)
783785 this ->kvec_d [i].z ,
784786 this ->wk [i]);
785787 }
786- GlobalV:: ofs_running << table << std::endl;
788+ ofs_running << table << std::endl;
787789
788790 this ->kd_done = true ;
789791 this ->kc_done = true ;
790792
791- this ->print_klists (GlobalV:: ofs_running);
793+ this ->print_klists (ofs_running);
792794}
793795
794796#ifdef __MPI
795- void K_Vectors::mpi_k ()
797+ void K_Vectors::mpi_k (std::ofstream& ofs_running )
796798{
797799 ModuleBase::TITLE (" K_Vectors" , " mpi_k" );
798800
@@ -815,8 +817,8 @@ void K_Vectors::mpi_k()
815817
816818 this ->nks = this ->para_k .nks_pool [GlobalV::MY_POOL ];
817819
818- GlobalV:: ofs_running << std::endl;
819- ModuleBase::GlobalFunc::OUT (GlobalV:: ofs_running, " Number of k-points in this process" , this ->nks );
820+ ofs_running << std::endl;
821+ ModuleBase::GlobalFunc::OUT (ofs_running, " Number of k-points in this process" , this ->nks );
820822 int nks_minimum = this ->nks ;
821823
822824 Parallel_Reduce::reduce_min (nks_minimum);
@@ -827,7 +829,7 @@ void K_Vectors::mpi_k()
827829 }
828830 else
829831 {
830- ModuleBase::GlobalFunc::OUT (GlobalV:: ofs_running, " Minimum distributed k-point number" , nks_minimum);
832+ ModuleBase::GlobalFunc::OUT (ofs_running, " Minimum distributed k-point number" , nks_minimum);
831833 }
832834
833835 std::vector<int > isk_aux (this ->nkstot );
0 commit comments