Skip to content

Commit e119b1f

Browse files
authored
Update output formats in running.log (#6053)
* update some timers * update timer * update output formats * update print_cell
1 parent c1c0b0b commit e119b1f

30 files changed

+135
-159
lines changed

source/driver_run.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
void Driver::driver_run()
2727
{
2828
ModuleBase::TITLE("Driver", "driver_line");
29-
ModuleBase::timer::tick("Driver", "driver_line");
3029

3130
//! 1: setup cell and atom information
3231
// this warning should not be here, mohan 2024-05-22
@@ -93,6 +92,5 @@ void Driver::driver_run()
9392

9493
//! 6: output the json file
9594
Json::create_Json(&ucell, PARAM);
96-
ModuleBase::timer::tick("Driver", "driver_line");
9795
return;
9896
}

source/module_basis/module_pw/pw_gatherscatter.h

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ModulePW
1414
template <typename T>
1515
void PW_Basis::gatherp_scatters(std::complex<T>* in, std::complex<T>* out) const
1616
{
17-
ModuleBase::timer::tick(this->classname, "gatherp_scatters");
17+
//ModuleBase::timer::tick(this->classname, "gatherp_scatters");
1818

1919
if(this->poolnproc == 1) //In this case nst=nstot, nz = nplane,
2020
{
@@ -32,7 +32,7 @@ void PW_Basis::gatherp_scatters(std::complex<T>* in, std::complex<T>* out) const
3232
outp[iz] = inp[iz];
3333
}
3434
}
35-
ModuleBase::timer::tick(this->classname, "gatherp_scatters");
35+
//ModuleBase::timer::tick(this->classname, "gatherp_scatters");
3636
return;
3737
}
3838
#ifdef __MPI
@@ -55,10 +55,15 @@ void PW_Basis::gatherp_scatters(std::complex<T>* in, std::complex<T>* out) const
5555

5656
//exchange data
5757
//(nplane,nstot) to (numz[ip],ns, poolnproc)
58-
if(typeid(T) == typeid(double))
59-
MPI_Alltoallv(out, numr, startr, MPI_DOUBLE_COMPLEX, in, numg, startg, MPI_DOUBLE_COMPLEX, this->pool_world);
60-
else if(typeid(T) == typeid(float))
61-
MPI_Alltoallv(out, numr, startr, MPI_COMPLEX, in, numg, startg, MPI_COMPLEX, this->pool_world);
58+
if(typeid(T) == typeid(double))
59+
{
60+
MPI_Alltoallv(out, numr, startr, MPI_DOUBLE_COMPLEX, in, numg, startg, MPI_DOUBLE_COMPLEX, this->pool_world);
61+
}
62+
else if(typeid(T) == typeid(float))
63+
{
64+
MPI_Alltoallv(out, numr, startr, MPI_COMPLEX, in, numg, startg, MPI_COMPLEX, this->pool_world);
65+
}
66+
6267
// change (nz,ns) to (numz[ip],ns, poolnproc)
6368
#ifdef _OPENMP
6469
#pragma omp parallel for collapse(2)
@@ -80,7 +85,7 @@ void PW_Basis::gatherp_scatters(std::complex<T>* in, std::complex<T>* out) const
8085
}
8186

8287
#endif
83-
ModuleBase::timer::tick(this->classname, "gatherp_scatters");
88+
//ModuleBase::timer::tick(this->classname, "gatherp_scatters");
8489
return;
8590
}
8691

@@ -94,7 +99,7 @@ void PW_Basis::gatherp_scatters(std::complex<T>* in, std::complex<T>* out) const
9499
template <typename T>
95100
void PW_Basis::gathers_scatterp(std::complex<T>* in, std::complex<T>* out) const
96101
{
97-
ModuleBase::timer::tick(this->classname, "gathers_scatterp");
102+
//ModuleBase::timer::tick(this->classname, "gathers_scatterp");
98103

99104
if(this->poolnproc == 1) //In this case nrxx=fftnx*fftny*nz, nst = nstot,
100105
{
@@ -147,10 +152,15 @@ void PW_Basis::gathers_scatterp(std::complex<T>* in, std::complex<T>* out) const
147152

148153
//exchange data
149154
//(numz[ip],ns, poolnproc) to (nplane,nstot)
150-
if(typeid(T) == typeid(double))
151-
MPI_Alltoallv(out, numg, startg, MPI_DOUBLE_COMPLEX, in, numr, startr, MPI_DOUBLE_COMPLEX, this->pool_world);
152-
else if(typeid(T) == typeid(float))
153-
MPI_Alltoallv(out, numg, startg, MPI_COMPLEX, in, numr, startr, MPI_COMPLEX, this->pool_world);
155+
if(typeid(T) == typeid(double))
156+
{
157+
MPI_Alltoallv(out, numg, startg, MPI_DOUBLE_COMPLEX, in, numr, startr, MPI_DOUBLE_COMPLEX, this->pool_world);
158+
}
159+
else if(typeid(T) == typeid(float))
160+
{
161+
MPI_Alltoallv(out, numg, startg, MPI_COMPLEX, in, numr, startr, MPI_COMPLEX, this->pool_world);
162+
}
163+
154164
#ifdef _OPENMP
155165
#pragma omp parallel for schedule(static, 4096/sizeof(T))
156166
#endif
@@ -175,10 +185,10 @@ void PW_Basis::gathers_scatterp(std::complex<T>* in, std::complex<T>* out) const
175185
}
176186

177187
#endif
178-
ModuleBase::timer::tick(this->classname, "gathers_scatterp");
188+
//ModuleBase::timer::tick(this->classname, "gathers_scatterp");
179189
return;
180190
}
181191

182192

183193

184-
}
194+
}

source/module_cell/klist.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void K_Vectors::set(const UnitCell& ucell,
5252
{
5353
ModuleBase::TITLE("K_Vectors", "set");
5454

55-
ofs << "\n\n\n\n";
55+
ofs << "\n\n";
5656
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
5757
ofs << " | |" << std::endl;
5858
ofs << " | Setup K-points |" << std::endl;
@@ -61,7 +61,7 @@ void K_Vectors::set(const UnitCell& ucell,
6161
ofs << " | We treat the spin as another set of k-points. |" << std::endl;
6262
ofs << " | |" << std::endl;
6363
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
64-
ofs << "\n\n\n\n";
64+
ofs << "\n\n";
6565

6666
ofs << "\n SETUP K-POINTS" << std::endl;
6767

source/module_cell/print_cell.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,16 @@ namespace unitcell
2323
bool direct = (Coordinate == "Direct");
2424
std::string table;
2525
table += direct? "DIRECT COORDINATES\n": FmtCore::format("CARTESIAN COORDINATES ( UNIT = %20.12f Bohr ).\n", lat0);
26-
const std::string redundant_header = direct? "taud_": "tauc_";
27-
table += FmtCore::format("%8s%20s%20s%20s%8s%20s%20s%20s\n", "atom", "x", "y", "z", "mag", "vx", "vy", "vz");
26+
table += FmtCore::format("%8s%10s%10s%10s%8s%8s%8s%8s\n", "atom", "x", "y", "z", "mag", "vx", "vy", "vz");
2827
for(int it = 0; it < ntype; it++)
2928
{
3029
for (int ia = 0; ia < atoms[it].na; ia++)
3130
{
3231
const double& x = direct? atoms[it].taud[ia].x: atoms[it].tau[ia].x;
3332
const double& y = direct? atoms[it].taud[ia].y: atoms[it].tau[ia].y;
3433
const double& z = direct? atoms[it].taud[ia].z: atoms[it].tau[ia].z;
35-
table += FmtCore::format("%5s%-s%-5d%20.10f%20.10f%20.10f%8.4f%20.10f%20.10f%20.10f\n", // I dont know why there must be a redundant "tau[c|d]_" in the output. So ugly, it should be removed!
36-
redundant_header,
34+
table += FmtCore::format("%8s%10.3f%10.3f%10.3f%8.3f%8.3f%8.3f%8.3f\n",
3735
atoms[it].label,
38-
ia+1,
3936
x,
4037
y,
4138
z,
@@ -140,4 +137,4 @@ namespace unitcell
140137
ofs.close();
141138
return;
142139
}
143-
}
140+
}

source/module_cell/test/unitcell_test.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,8 @@ TEST_F(UcellTest, PrintTauDirect)
10181018
ifs.open("print_tau_direct");
10191019
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
10201020
EXPECT_THAT(str, testing::HasSubstr("DIRECT COORDINATES"));
1021-
EXPECT_THAT(str, testing::HasSubstr("taud_C1 0.1000000000 0.1000000000 0.1000000000"));
1021+
EXPECT_THAT(str, testing::HasSubstr(" C 0.100 0.100 0.100 0.000 0.100 0.100 0.100"));
1022+
EXPECT_THAT(str, testing::HasSubstr(" H 0.150 0.150 0.150 0.000 0.100 0.100 0.100"));
10221023
ifs.close();
10231024
remove("print_tau_direct");
10241025
}
@@ -1036,7 +1037,8 @@ TEST_F(UcellTest, PrintTauCartesian)
10361037
ifs.open("print_tau_Cartesian");
10371038
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
10381039
EXPECT_THAT(str, testing::HasSubstr("CARTESIAN COORDINATES"));
1039-
EXPECT_THAT(str, testing::HasSubstr("tauc_C1 1.0000000000 1.0000000000 1.0000000000"));
1040+
EXPECT_THAT(str, testing::HasSubstr(" C 1.000 1.000 1.000 0.000 0.000 0.000 0.000"));
1041+
EXPECT_THAT(str, testing::HasSubstr(" H 1.500 1.500 1.500 0.000 0.000 0.000 0.000"));
10401042
ifs.close();
10411043
remove("print_tau_Cartesian");
10421044
}

source/module_cell/unitcell.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log) {
214214

215215
if (ok)
216216
{
217-
log << "\n\n\n\n";
217+
log << "\n\n";
218218
log << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
219219
">>>>>>>>>>>>"
220220
<< std::endl;
@@ -254,7 +254,7 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log) {
254254
log << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
255255
"<<<<<<<<<<<<"
256256
<< std::endl;
257-
log << "\n\n\n\n";
257+
log << "\n\n";
258258

259259
log << " READING UNITCELL INFORMATION" << std::endl;
260260
//========================
@@ -560,4 +560,4 @@ void UnitCell::compare_atom_labels(std::string label1, std::string label2) {
560560
}
561561
}
562562
}
563-
}
563+
}

source/module_elecstate/module_charge/charge_mixing.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,24 @@ void Charge_Mixing::set_mixing(const std::string& mixing_mode_in,
5858
}
5959

6060
// print into running.log
61-
GlobalV::ofs_running<<"\n----------- Double Check Mixing Parameters Begin ------------"<<std::endl;
62-
GlobalV::ofs_running<<"mixing_type: "<< this->mixing_mode <<std::endl;
63-
GlobalV::ofs_running<<"mixing_beta: "<< this->mixing_beta <<std::endl;
64-
GlobalV::ofs_running<<"mixing_gg0: "<< this->mixing_gg0 <<std::endl;
65-
GlobalV::ofs_running<<"mixing_gg0_min: "<< PARAM.inp.mixing_gg0_min <<std::endl;
61+
GlobalV::ofs_running<<"\n ----------- Charge Mixing Parameters ------------"<<std::endl;
62+
63+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "mixing_type", this->mixing_mode);
64+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "mixing_beta", this->mixing_beta);
65+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "mixing_gg0", this->mixing_gg0);
66+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "mixing_gg0_min", PARAM.inp.mixing_gg0_min);
67+
6668
if (PARAM.inp.nspin==2 || PARAM.inp.nspin==4)
6769
{
68-
GlobalV::ofs_running<<"mixing_beta_mag: "<< this->mixing_beta_mag <<std::endl;
69-
GlobalV::ofs_running<<"mixing_gg0_mag: "<< PARAM.inp.mixing_gg0_mag <<std::endl;
70+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "mixing_beta_mag", this->mixing_beta_mag);
71+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "mixing_gg0_mag", PARAM.inp.mixing_gg0_mag);
7072
}
7173
if (PARAM.inp.mixing_angle > 0)
7274
{
73-
GlobalV::ofs_running<<"mixing_angle: "<< PARAM.inp.mixing_angle <<std::endl;
75+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "mixing_angle", PARAM.inp.mixing_angle);
7476
}
75-
GlobalV::ofs_running<<"mixing_ndim: "<< this->mixing_ndim <<std::endl;
76-
GlobalV::ofs_running<<"----------- Double Check Mixing Parameters End ------------"<<std::endl;
77+
78+
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "mixing_ndim", this->mixing_ndim);
7779

7880
return;
7981
}
@@ -240,4 +242,4 @@ bool Charge_Mixing::if_scf_oscillate(const int iteration, const double drho, con
240242
}
241243

242244
return false;
243-
}
245+
}

source/module_elecstate/potentials/pot_xc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace elecstate
1212

1313
void PotXC::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix& v_eff)
1414
{
15-
ModuleBase::TITLE("PotXC", "cal_v_eff");
16-
ModuleBase::timer::tick("PotXC", "cal_v_eff");
15+
ModuleBase::TITLE("PotXC", "cal_veff");
16+
ModuleBase::timer::tick("PotXC", "cal_veff");
1717
const int nrxx_current = chg->nrxx;
1818

1919
//----------------------------------------------------------
@@ -41,7 +41,7 @@ void PotXC::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, Module
4141
*(this->vtxc_) = std::get<1>(etxc_vtxc_v);
4242
v_eff += std::get<2>(etxc_vtxc_v);
4343
}
44-
ModuleBase::timer::tick("PotXC", "cal_v_eff");
44+
ModuleBase::timer::tick("PotXC", "cal_veff");
4545
}
4646

47-
} // namespace elecstate
47+
} // namespace elecstate

source/module_elecstate/potentials/potential_new.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ void Potential::allocate()
163163
void Potential::update_from_charge(const Charge*const chg, const UnitCell*const ucell)
164164
{
165165
ModuleBase::TITLE("Potential", "update_from_charge");
166-
ModuleBase::timer::tick("Potential", "update_from_charge");
166+
//ModuleBase::timer::tick("Potential", "update_from_charge");
167+
167168
if (!this->fixed_done)
168169
{
169170
this->cal_fixed_v(this->v_effective_fixed.data());
@@ -216,13 +217,14 @@ void Potential::update_from_charge(const Charge*const chg, const UnitCell*const
216217
}
217218
#endif
218219

219-
ModuleBase::timer::tick("Potential", "update_from_charge");
220+
//ModuleBase::timer::tick("Potential", "update_from_charge");
220221
}
221222

222223
void Potential::cal_fixed_v(double* vl_pseudo)
223224
{
224225
ModuleBase::TITLE("Potential", "cal_fixed_v");
225226
ModuleBase::timer::tick("Potential", "cal_fixed_v");
227+
226228
this->v_effective_fixed.assign(this->v_effective_fixed.size(), 0.0);
227229
for (size_t i = 0; i < this->components.size(); i++)
228230
{
@@ -237,10 +239,11 @@ void Potential::cal_fixed_v(double* vl_pseudo)
237239

238240
void Potential::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix& v_eff)
239241
{
240-
ModuleBase::TITLE("Potential", "cal_v_eff");
242+
ModuleBase::TITLE("Potential", "cal_veff");
243+
ModuleBase::timer::tick("Potential", "cal_veff");
244+
241245
const int nspin_current = this->v_effective.nr;
242246
const int nrxx = this->v_effective.nc;
243-
ModuleBase::timer::tick("Potential", "cal_v_eff");
244247
// first of all, set v_effective to zero.
245248
this->v_effective.zero_out();
246249

@@ -264,7 +267,7 @@ void Potential::cal_v_eff(const Charge*const chg, const UnitCell*const ucell, Mo
264267
}
265268
}
266269

267-
ModuleBase::timer::tick("Potential", "cal_v_eff");
270+
ModuleBase::timer::tick("Potential", "cal_veff");
268271
}
269272

270273
void Potential::init_pot(int istep, const Charge*const chg)
@@ -278,8 +281,6 @@ void Potential::init_pot(int istep, const Charge*const chg)
278281

279282
this->update_from_charge(chg, this->ucell_);
280283

281-
// plots
282-
// figure::picture(this->vr_eff1,GlobalC::rhopw->nx,GlobalC::rhopw->ny,GlobalC::rhopw->nz);
283284
ModuleBase::timer::tick("Potential", "init_pot");
284285
return;
285286
}

source/module_elecstate/read_pseudo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace elecstate {
1212
void read_pseudo(std::ofstream& ofs, UnitCell& ucell) {
1313
// read in non-local pseudopotential and ouput the projectors.
14-
ofs << "\n\n\n\n";
14+
ofs << "\n\n";
1515
ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
1616
">>>>"
1717
<< std::endl;
@@ -54,7 +54,7 @@ void read_pseudo(std::ofstream& ofs, UnitCell& ucell) {
5454
ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
5555
"<<<<"
5656
<< std::endl;
57-
ofs << "\n\n\n\n";
57+
ofs << "\n\n";
5858

5959
read_cell_pseudopots(PARAM.inp.pseudo_dir, ofs, ucell);
6060

@@ -368,4 +368,4 @@ void print_unitcell_pseudo(const std::string& fn, UnitCell& ucell)
368368
return;
369369
}
370370

371-
}
371+
}

0 commit comments

Comments
 (0)