1212#include " module_hamilt_pw/hamilt_pwdft/parallel_grid.h"
1313#include " module_io/read_wf2rho_pw.h"
1414#include " module_io/write_wfc_pw.h"
15+ #include " module_io/filename.h" // mohan add 2025-05-17
1516#include " module_parameter/parameter.h"
1617#include " module_psi/psi.h"
1718
@@ -219,10 +220,11 @@ TEST_F(ReadWfcRhoTest, ReadWfcRho)
219220#endif
220221
221222 // Write the wave functions to file
222- ModuleIO::write_wfc_pw (" WAVEFUNC" , *psi, *kv, wfcpw);
223+ const std::string global_out_dir = " ./" ;
224+ ModuleIO::write_wfc_pw (PARAM.input .out_wfc_pw , global_out_dir, *psi, *kv, wfcpw);
223225
224226 // Read the wave functions to charge density
225- ModuleIO::read_wf2rho_pw (wfcpw, symm, kv->ik2iktot . data () , nkstot, kv->isk , chg);
227+ ModuleIO::read_wf2rho_pw (wfcpw, symm, kv->ik2iktot , nkstot, kv->isk , chg);
226228
227229 // compare the charge density
228230 for (int ir = 0 ; ir < rhopw->nrxx ; ++ir)
@@ -231,22 +233,24 @@ TEST_F(ReadWfcRhoTest, ReadWfcRho)
231233 }
232234 // std::cout.precision(16);
233235 // std::cout<<chg.rho[0][0]<<std::endl;
234- if (GlobalV::NPROC == 1 ) {
235- EXPECT_NEAR (chg.rho [0 ][0 ], 8617.076357957576 , 1e-8 );
236- } else if (GlobalV::NPROC == 4 )
237- {
238- const std::vector<double > ref = {8207.849135313403 , 35.34776105132742 , 8207.849135313403 , 35.34776105132742 };
239- EXPECT_NEAR (chg.rho [0 ][0 ], ref[GlobalV::MY_RANK], 1e-8 );
240- // for (int ip = 0; ip < GlobalV::NPROC; ++ip)
241- // {
242- // if (GlobalV::MY_RANK == ip)
243- // {
244- // std::cout.precision(16);
245- // std::cout << GlobalV::MY_RANK << " " << chg.rho[0][0] << std::endl;
246- // }
247- // MPI_Barrier(MPI_COMM_WORLD);
248- // }
249- }
236+ if (GlobalV::NPROC == 1 )
237+ {
238+ EXPECT_NEAR (chg.rho [0 ][0 ], 8617.076357957576 , 1e-8 );
239+ }
240+ else if (GlobalV::NPROC == 4 )
241+ {
242+ const std::vector<double > ref = {8207.849135313403 , 35.34776105132742 , 8207.849135313403 , 35.34776105132742 };
243+ EXPECT_NEAR (chg.rho [0 ][0 ], ref[GlobalV::MY_RANK], 1e-8 );
244+ // for (int ip = 0; ip < GlobalV::NPROC; ++ip)
245+ // {
246+ // if (GlobalV::MY_RANK == ip)
247+ // {
248+ // std::cout.precision(16);
249+ // std::cout << GlobalV::MY_RANK << " " << chg.rho[0][0] << std::endl;
250+ // }
251+ // MPI_Barrier(MPI_COMM_WORLD);
252+ // }
253+ }
250254
251255 delete[] chg.rho ;
252256 delete[] chg._space_rho ;
0 commit comments