@@ -616,44 +616,48 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
616616 // we only print information every few ionic steps
617617 // ----------------------------------------------------------
618618
619+ // if istep_in = -1, istep will not appear in file name
620+ // if iter_in = -1, iter will not appear in file name
621+ int istep_in = -1 ;
622+ int iter_in = -1 ;
623+ bool out_wfc_flag = false ;
619624 if (PARAM.inp .out_freq_ion >0 ) // default value of out_freq_ion is 0
620625 {
621626 if (istep % PARAM.inp .out_freq_ion == 0 )
622627 {
623- if (iter % PARAM.inp .out_freq_elec == 0 || iter == PARAM.inp .scf_nmax || conv_esolver)
628+ if (iter % PARAM.inp .out_freq_elec == 0 || iter == PARAM.inp .scf_nmax || conv_esolver)
624629 {
625- // if iter_in = -1, iter will not appear in file name
626- int iter_in = -1 ;
627- if (iter % PARAM.inp .out_freq_elec == 0 )
628- {
629- iter_in = iter;
630- }
631-
632- int istep_in = istep;
633- if (PARAM.inp .calculation == " scf" || PARAM.inp .calculation == " nscf" )
634- {
635- istep_in = -1 ;
636- }
637-
638- ModuleIO::write_wfc_pw (istep_in, iter_in,
639- GlobalV::KPAR,
640- GlobalV::MY_POOL,
641- GlobalV::MY_RANK,
642- PARAM.inp .nbands ,
643- PARAM.inp .nspin ,
644- PARAM.globalv .npol ,
645- GlobalV::RANK_IN_POOL,
646- GlobalV::NPROC_IN_POOL,
647- PARAM.inp .out_wfc_pw ,
648- PARAM.inp .ecutwfc ,
649- PARAM.globalv .global_out_dir ,
650- this ->psi [0 ],
651- this ->kv ,
652- this ->pw_wfc ,
653- GlobalV::ofs_running);
630+ istep_in = istep;
631+ iter_in = iter;
632+ out_wfc_flag = true ;
654633 }
655634 }
656635 }
636+ else if (iter == PARAM.inp .scf_nmax || conv_esolver)
637+ {
638+ out_wfc_flag = true ;
639+ }
640+
641+
642+ if (out_wfc_flag)
643+ {
644+ ModuleIO::write_wfc_pw (istep_in, iter_in,
645+ GlobalV::KPAR,
646+ GlobalV::MY_POOL,
647+ GlobalV::MY_RANK,
648+ PARAM.inp .nbands ,
649+ PARAM.inp .nspin ,
650+ PARAM.globalv .npol ,
651+ GlobalV::RANK_IN_POOL,
652+ GlobalV::NPROC_IN_POOL,
653+ PARAM.inp .out_wfc_pw ,
654+ PARAM.inp .ecutwfc ,
655+ PARAM.globalv .global_out_dir ,
656+ this ->psi [0 ],
657+ this ->kv ,
658+ this ->pw_wfc ,
659+ GlobalV::ofs_running);
660+ }
657661
658662 // ----------------------------------------------------------
659663 // 4) check if oscillate for delta_spin method
0 commit comments