Skip to content

Commit a5da637

Browse files
committed
update file names in 08_EXX example
1 parent 199e138 commit a5da637

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+49
-28
lines changed

source/module_io/read_wfc_lcao.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
340353
template 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+
350364
template 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+
360375
template 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+
370386
template 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
438455
template 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+
447465
template 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+
456475
template 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+
465485
template void ModuleIO::restart_from_file(const std::string& out_dir,
466486
const int& nks,
467487
int& nbands,

source/module_io/read_wfc_lcao.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <complex>
88
#include <string>
99
#include <vector>
10+
1011
#ifdef __MPI
1112
// parallelization
1213
#include "module_base/scalapack_connector.h"
@@ -110,4 +111,4 @@ void restart_from_file(const std::string& out_dir, // hard-code the file name to
110111
std::vector<double>& occ, std::vector<ModuleBase::Vector3<double>>& kvec_c,
111112
std::vector<double>& wk);
112113
} // namespace ModuleIO
113-
#endif
114+
#endif

source/module_io/test/read_wfc_lcao_test.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ TEST(ReadWfcLcaoTest, ReadAbacusLowfComplex)
2828
double wk = -1.0;
2929

3030
// first test
31-
std::string flowf = "./support/WFC_NAO_K1.txt";
31+
std::string flowf = "./support/wfs1k1_nao.txt";
3232
ModuleIO::read_abacus_lowf(flowf, ik, kvec_c, nbands, nbasis, lowf, ekb, occ, wk);
3333
EXPECT_EQ(1, ik);
3434
EXPECT_EQ(3, nbands);
@@ -59,7 +59,7 @@ TEST(ReadWfcLcaoTest, ReadAbacusLowfComplex)
5959
EXPECT_NEAR(lowf[62].real(), 1.82648757e-03, 1e-7);
6060
EXPECT_NEAR(lowf[62].imag(), -2.11799886e-03, 1e-7);
6161
// test reuse, expect to overwrite the previous values
62-
flowf = "./support/WFC_NAO_K2.txt";
62+
flowf = "./support/wfs1k2_nao.txt";
6363
ModuleIO::read_abacus_lowf(flowf, ik, kvec_c, nbands, nbasis, lowf, ekb, occ, wk);
6464
EXPECT_EQ(2, ik);
6565
EXPECT_EQ(3, nbands);
@@ -90,7 +90,7 @@ TEST(ReadWfcLcaoTest, ReadAbacusLowfComplex)
9090
EXPECT_NEAR(lowf[62].real(), -1.15158489e-03, 1e-7);
9191
EXPECT_NEAR(lowf[62].imag(), -1.79940038e-03, 1e-7);
9292
// test reuse, the second time
93-
flowf = "./support/WFC_NAO_K3.txt";
93+
flowf = "./support/wfs1k3_nao.txt";
9494
ModuleIO::read_abacus_lowf(flowf, ik, kvec_c, nbands, nbasis, lowf, ekb, occ, wk);
9595
EXPECT_EQ(3, ik);
9696
EXPECT_EQ(3, nbands);
@@ -328,7 +328,7 @@ TEST(ReadWfcLcaoTest, ReadAbacusLowfReal)
328328
double wk = -1.0; // should be overwritten to 1.0
329329

330330
// first test
331-
const std::string flowf = "./support/WFC_NAO_GAMMA1.txt";
331+
const std::string flowf = "./support/wfs2_nao.txt";
332332
ModuleIO::read_abacus_lowf(flowf, ik, kvec_c, nbands, nbasis, lowf, ekb, occ, wk);
333333
EXPECT_EQ(0, ik);
334334
EXPECT_EQ(3, nbands);
@@ -680,7 +680,7 @@ TEST(ReadWfcLcaoTest, RestartFromFileSerial)
680680
std::vector<double> occ_k0;
681681
ModuleBase::Vector3<double> kvec_c_k0;
682682
double wk_k0 = -1.0;
683-
ModuleIO::read_abacus_lowf("./support/WFC_NAO_K1.txt", ik_k0, kvec_c_k0, nbands_k0, nbasis_k0, lowf_k0, ekb_k0,
683+
ModuleIO::read_abacus_lowf("./support/wfs1k1_nao.txt", ik_k0, kvec_c_k0, nbands_k0, nbasis_k0, lowf_k0, ekb_k0,
684684
occ_k0, wk_k0);
685685

686686
EXPECT_EQ(1, ik_k0);
@@ -717,7 +717,7 @@ TEST(ReadWfcLcaoTest, RestartFromFileSerial)
717717
std::vector<double> occ_k1;
718718
ModuleBase::Vector3<double> kvec_c_k1;
719719
double wk_k1 = -1.0;
720-
ModuleIO::read_abacus_lowf("./support/WFC_NAO_K2.txt", ik_k1, kvec_c_k1, nbands_k1, nbasis_k1, lowf_k1, ekb_k1,
720+
ModuleIO::read_abacus_lowf("./support/wfs1k2_nao.txt", ik_k1, kvec_c_k1, nbands_k1, nbasis_k1, lowf_k1, ekb_k1,
721721
occ_k1, wk_k1);
722722

723723
EXPECT_EQ(2, ik_k1);
@@ -769,4 +769,4 @@ int main(int argc, char** argv)
769769
MPI_Finalize();
770770
#endif
771771
return status;
772-
}
772+
}
-8.29 KB
Binary file not shown.
File renamed without changes.

0 commit comments

Comments
 (0)