Skip to content

Commit 5580c34

Browse files
committed
fix compilation error when MPI is disabled
1 parent 12a1883 commit 5580c34

File tree

7 files changed

+21
-12
lines changed

7 files changed

+21
-12
lines changed

source/module_hamilt_lcao/module_gint/temp_gint/gint_common.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void transfer_dm_2d_to_gint(
167167
HContainer<T> dm_full = gint_info.get_hr<T>(npol);
168168
hamilt::transferParallels2Serials(*dm[0], &dm_full);
169169
#else
170-
HContainer<T>& dm_full = dm[0];
170+
HContainer<T>& dm_full = *(dm[0]);
171171
#endif
172172
std::vector<T*> tmp_pointer(4, nullptr);
173173
for (int iap = 0; iap < dm_full.size_atom_pairs(); iap++)
@@ -220,18 +220,20 @@ int localIndex(int globalindex, int nblk, int nprocs, int& myproc)
220220

221221
template <typename T>
222222
void wfc_2d_to_gint(const T* wfc_2d,
223+
int nbands, // needed if MPI is disabled
224+
int nlocal, // needed if MPI is disabled
223225
const Parallel_Orbitals& pv,
224226
T* wfc_gint,
225227
const GintInfo& gint_info)
226228
{
227229
ModuleBase::TITLE("Gint", "wfc_2d_to_gint");
228230
ModuleBase::timer::tick("Gint", "wfc_2d_to_gint");
229231

232+
#ifdef __MPI
230233
// dimension related
231-
const int nlocal = pv.desc_wfc[2];
232-
const int nbands = pv.desc_wfc[3];
234+
nlocal = pv.desc_wfc[2];
235+
nbands = pv.desc_wfc[3];
233236

234-
#ifdef __MPI
235237
const std::vector<int>& trace_lo = gint_info.get_trace_lo();
236238

237239
// MPI and memory related
@@ -303,7 +305,7 @@ void wfc_2d_to_gint(const T* wfc_2d,
303305
{
304306
for (int j = 0; j < nlocal; ++j)
305307
{
306-
wfc_k_grid[i * nlocal + j] = psi[0](i, j);
308+
wfc_gint[i * nlocal + j] = wfc_2d[i * nlocal + j];
307309
}
308310
}
309311
#endif
@@ -326,11 +328,15 @@ template void transfer_dm_2d_to_gint(
326328
std::vector<HContainer<std::complex<double>>>& dm_gint);
327329
template void wfc_2d_to_gint(
328330
const double* wfc_2d,
331+
int nbands,
332+
int nlocal,
329333
const Parallel_Orbitals& pv,
330334
double* wfc_grid,
331335
const GintInfo& gint_info);
332336
template void wfc_2d_to_gint(
333337
const std::complex<double>* wfc_2d,
338+
int nbands,
339+
int nlocal,
334340
const Parallel_Orbitals& pv,
335341
std::complex<double>* wfc_grid,
336342
const GintInfo& gint_info);

source/module_hamilt_lcao/module_gint/temp_gint/gint_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ namespace ModuleGint
2020
std::vector<HContainer<T>>& dm_gint);
2121

2222
template<typename T>
23-
void wfc_2d_to_gint(const T* wfc_2d, const Parallel_Orbitals& pv, T* wfc_grid, const GintInfo& gint_info);
23+
void wfc_2d_to_gint(const T* wfc_2d, int nbands, int nlocal, const Parallel_Orbitals& pv, T* wfc_grid, const GintInfo& gint_info);
2424
}

source/module_hamilt_lcao/module_gint/temp_gint/gint_env_gamma.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ Gint_env_gamma::Gint_env_gamma(
99
const double* psid,
1010
const Parallel_Orbitals* pv,
1111
const int nbands,
12+
const int nlocal,
1213
double* rho)
1314
:rho_(rho)
1415
{
1516
wfc_gint_.resize(nbands * gint_info_->get_lgd());
16-
wfc_2d_to_gint(psid, *pv, wfc_gint_.data(), *gint_info_);
17+
wfc_2d_to_gint(psid, nbands, nlocal, *pv, wfc_gint_.data(), *gint_info_);
1718
}
1819

1920
void Gint_env_gamma::cal_env_band(const int iband)

source/module_hamilt_lcao/module_gint/temp_gint/gint_env_gamma.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ class Gint_env_gamma : public Gint
1616
const double* psid,
1717
const Parallel_Orbitals* pv,
1818
const int nbands,
19+
const int nlocal,
1920
double* rho);
2021

2122
void cal_env_band(const int iband);
2223

2324
private:
24-
2525
// output
2626
double* rho_;
2727

source/module_hamilt_lcao/module_gint/temp_gint/gint_env_k.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ Gint_env_k::Gint_env_k(
1111
const std::vector<Vec3d>& kvec_c,
1212
const std::vector<Vec3d>& kvec_d,
1313
const int nbands,
14+
const int nlocal,
1415
const int ik,
1516
const int nspin,
1617
const int npol,
1718
double* rho)
1819
:kvec_c_(kvec_c), kvec_d_(kvec_d), ik_(ik), nspin_(nspin), npol_(npol), rho_(rho)
1920
{
2021
wfc_gint_.resize(nbands * gint_info_->get_lgd());
21-
wfc_2d_to_gint(psid, *pv, wfc_gint_.data(), *gint_info_);
22+
wfc_2d_to_gint(psid, nbands, nlocal, *pv, wfc_gint_.data(), *gint_info_);
2223
}
2324

2425
void Gint_env_k::cal_env_band(const int iband)

source/module_hamilt_lcao/module_gint/temp_gint/gint_env_k.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Gint_env_k : public Gint
1818
const std::vector<Vec3d>& kvec_c,
1919
const std::vector<Vec3d>& kvec_d,
2020
const int nbands,
21+
const int nlocal,
2122
const int ik,
2223
const int nspin,
2324
const int npol,

source/module_io/get_wf_lcao.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
112112
}
113113
#endif
114114
#else
115-
ModuleGint::Gint_env_gamma gint_env(psid->get_pointer(), &para_orb, nbands, pes_->charge->rho[is]);
115+
ModuleGint::Gint_env_gamma gint_env(psid->get_pointer(), &para_orb, nbands, nlocal, pes_->charge->rho[is]);
116116
#endif
117117
for (int ib = 0; ib < nbands; ++ib)
118118
{
@@ -189,7 +189,7 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
189189
}
190190
#endif
191191
#else
192-
ModuleGint::Gint_env_gamma gint_env(psid->get_pointer(), &para_orb, nbands, pes_->charge->rho[is]);
192+
ModuleGint::Gint_env_gamma gint_env(psid->get_pointer(), &para_orb, nbands, nlocal, pes_->charge->rho[is]);
193193
#endif
194194
for (int ib = 0; ib < nbands; ++ib)
195195
{
@@ -341,7 +341,7 @@ void Get_wf_lcao::begin(const UnitCell& ucell,
341341
#endif
342342
#else
343343
ModuleGint::Gint_env_k gint_env(psi->get_pointer(), &para_orb, kv.kvec_c, kv.kvec_d,
344-
nbands, ik, PARAM.inp.nspin, PARAM.globalv.npol, pes_->charge->rho[ispin]);
344+
nbands, nlocal, ik, PARAM.inp.nspin, PARAM.globalv.npol, pes_->charge->rho[ispin]);
345345
#endif
346346

347347
for (int ib = 0; ib < nbands; ++ib)

0 commit comments

Comments
 (0)