Skip to content

Commit e99d344

Browse files
authored
[Refactor] Remove parameter.h is some files in source_basis (deepmodeling#7365)
* Remove parameter.h * Continue remove parameter.h * Remove parameter.h dependency in pw_basis * Remove dependency in pw_basis_k
1 parent b5ff54c commit e99d344

22 files changed

Lines changed: 88 additions & 40 deletions

source/source_base/module_device/memory_op.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,11 @@ void set_dsp_cluster_id(int id)
452452
g_dsp_cluster_id = id;
453453
}
454454

455+
int get_dsp_cluster_id()
456+
{
457+
return g_dsp_cluster_id;
458+
}
459+
455460
template <typename FPTYPE>
456461
struct resize_memory_op_mt<FPTYPE, base_device::DEVICE_CPU>
457462
{

source/source_base/module_device/memory_op.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ struct delete_memory_op<FPTYPE, base_device::DEVICE_GPU>
225225
/// Defaults to 0 if never set.
226226
void set_dsp_cluster_id(int id);
227227

228+
/// @brief Read back the injected DSP cluster id. Returns 0 if never set.
229+
int get_dsp_cluster_id();
230+
228231
template <typename FPTYPE, typename Device>
229232
struct resize_memory_op_mt
230233
{

source/source_base/tool_quit.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ namespace ModuleBase
1717
namespace
1818
{
1919
std::string g_quit_out_dir;
20+
std::string g_quit_calculation;
2021
}
2122

2223
void set_quit_out_dir(const std::string& dir)
2324
{
2425
g_quit_out_dir = dir;
2526
}
2627

28+
void set_quit_calculation(const std::string& calculation)
29+
{
30+
g_quit_calculation = calculation;
31+
}
32+
2733
//==========================================================
2834
// GLOBAL FUNCTION :
2935
// NAME : WARNING( write information into GlobalV::ofs_warning)
@@ -139,7 +145,7 @@ void WARNING_QUIT(const std::string &file,const std::string &description,int ret
139145

140146
//Check and print warning information for all cores.
141147
//Maybe in the future warning.log should be replaced by error.log.
142-
void CHECK_WARNING_QUIT(const bool error_in, const std::string &file,const std::string &calculation,const std::string &description)
148+
void CHECK_WARNING_QUIT(const bool error_in, const std::string &file, const std::string &description)
143149
{
144150
#ifdef __NORMAL
145151
if(error_in) std::cout << description << std::endl;
@@ -150,7 +156,7 @@ void CHECK_WARNING_QUIT(const bool error_in, const std::string &file,const std::
150156
std::cout.clear();
151157
if(!GlobalV::ofs_running.is_open())
152158
{
153-
std::string logfile = g_quit_out_dir + "running_" + calculation + ".log";
159+
std::string logfile = g_quit_out_dir + "running_" + g_quit_calculation + ".log";
154160
GlobalV::ofs_running.open( logfile.c_str(), std::ios::app );
155161
}
156162
if(!GlobalV::ofs_warning.is_open())

source/source_base/tool_quit.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ void WARNING(const std::string &file, const std::string &description);
3737
*/
3838
void set_quit_out_dir(const std::string& dir);
3939

40+
/**
41+
* @brief Inject the calculation tag used by CHECK_WARNING_QUIT to compose the
42+
* fallback log filename ("running_<calculation>.log") when ofs_running
43+
* is not already open.
44+
*
45+
* Caller-injected (typically once after input parameters are read).
46+
* If never set, the fallback filename uses an empty tag.
47+
*/
48+
void set_quit_calculation(const std::string& calculation);
49+
4050
/**
4151
* @brief Close .log files and exit
4252
*
@@ -71,7 +81,7 @@ void set_quit_out_dir(const std::string& dir);
7181
* @param file The file where warning happens
7282
* @param description The warning information
7383
*/
74-
void CHECK_WARNING_QUIT(const bool error, const std::string &file,const std::string &calculation,const std::string &description);
84+
void CHECK_WARNING_QUIT(const bool error, const std::string &file, const std::string &description);
7585

7686
} // namespace ModuleBase
7787

source/source_basis/module_ao/ORB_read.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "source_base/parallel_common.h"
55
#include "source_base/timer.h"
66
#include "source_base/tool_check.h"
7-
#include "source_io/module_parameter/parameter.h"
87

98
#include <algorithm>
109
#include <cassert>
@@ -58,6 +57,7 @@ void LCAO_Orbitals::init(
5857
const double& lcao_rmax_in,
5958
const bool& deepks_setorb,
6059
const int& out_mat_r,
60+
const bool& out_element_info,
6161
const bool& force_flag,
6262
const int& my_rank
6363
)
@@ -86,7 +86,7 @@ void LCAO_Orbitals::init(
8686
#ifdef __MPI
8787
bcast_files(ntype, my_rank);
8888
#endif
89-
Read_Orbitals(ofs_in, ntype, lmax, deepks_setorb, out_mat_r, force_flag, my_rank);
89+
Read_Orbitals(ofs_in, ntype, lmax, deepks_setorb, out_mat_r, out_element_info, force_flag, my_rank);
9090
return;
9191
}
9292

@@ -156,6 +156,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in,
156156
const int& lmax_in,
157157
const bool& deepks_setorb,
158158
const int& out_mat_r,
159+
const bool& out_element_info,
159160
const bool& force_flag, // mohan add 2021-05-07
160161
const int& my_rank) // mohan add 2021-04-26
161162
{
@@ -247,7 +248,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in,
247248
this->Phi = new Numerical_Orbital[ntype];
248249
for (int it = 0; it < ntype; it++)
249250
{
250-
this->Read_PAO(ofs_in, it, force_flag, my_rank);
251+
this->Read_PAO(ofs_in, it, out_element_info, force_flag, my_rank);
251252
// caoyu add 2021-05-24 to reconstruct atom_arrange::set_sr_NL
252253
this->rcutmax_Phi = std::max(this->rcutmax_Phi, this->Phi[it].getRcut());
253254
}
@@ -263,7 +264,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in,
263264

264265
delete[] this->Alpha;
265266
this->Alpha = new Numerical_Orbital[1]; // not related to atom type -- remain to be discussed
266-
this->Read_Descriptor(ofs_in, force_flag, my_rank);
267+
this->Read_Descriptor(ofs_in, out_element_info, force_flag, my_rank);
267268
}
268269

269270
ModuleBase::timer::end("LCAO_Orbitals", "Read_Orbitals");
@@ -279,6 +280,7 @@ void LCAO_Orbitals::Read_Orbitals(std::ofstream& ofs_in,
279280
//-------------------------------------------------------
280281
void LCAO_Orbitals::Read_PAO(std::ofstream& ofs_in,
281282
const int& it,
283+
const bool& out_element_info,
282284
const bool& force_flag, // mohan add 2021-05-07
283285
const int& my_rank) // mohan add 2021-04-26
284286
{
@@ -311,7 +313,7 @@ void LCAO_Orbitals::Read_PAO(std::ofstream& ofs_in,
311313
int lmaxt = 0;
312314
int nchimaxt = 0;
313315

314-
this->read_orb_file(ofs_in, in_ao, it, lmaxt, nchimaxt, this->Phi, force_flag, my_rank);
316+
this->read_orb_file(ofs_in, in_ao, it, lmaxt, nchimaxt, this->Phi, out_element_info, force_flag, my_rank);
315317

316318
// lmax and nchimax for all types
317319
this->lmax = std::max(this->lmax, lmaxt);
@@ -323,6 +325,7 @@ void LCAO_Orbitals::Read_PAO(std::ofstream& ofs_in,
323325

324326
// caoyu add 2021-3-16
325327
void LCAO_Orbitals::Read_Descriptor(std::ofstream& ofs_in,
328+
const bool& out_element_info,
326329
const bool& force_flag, // mohan add 2021-05-07
327330
const int& my_rank) // read descriptor basis
328331
{
@@ -355,7 +358,7 @@ void LCAO_Orbitals::Read_Descriptor(std::ofstream& ofs_in,
355358
this->lmax_d = 0;
356359
this->nchimax_d = 0;
357360

358-
this->read_orb_file(ofs_in, in_de, 0, this->lmax_d, this->nchimax_d, this->Alpha, force_flag, my_rank);
361+
this->read_orb_file(ofs_in, in_de, 0, this->lmax_d, this->nchimax_d, this->Alpha, out_element_info, force_flag, my_rank);
359362

360363
in_de.close();
361364

@@ -368,6 +371,7 @@ void LCAO_Orbitals::read_orb_file(std::ofstream& ofs_in, // GlobalV::ofs_running
368371
int& lmax,
369372
int& nchimax,
370373
Numerical_Orbital* ao,
374+
const bool& out_element_info,
371375
const bool& force_flag,
372376
const int& my_rank)
373377
{
@@ -588,7 +592,7 @@ void LCAO_Orbitals::read_orb_file(std::ofstream& ofs_in, // GlobalV::ofs_running
588592
this->kmesh,
589593
this->dk,
590594
this->dr_uniform,
591-
PARAM.inp.out_element_info,
595+
out_element_info,
592596
true,
593597
force_flag); // delta k mesh in reciprocal space
594598

source/source_basis/module_ao/ORB_read.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class LCAO_Orbitals
3434
const double& lcao_rmax_in,
3535
const bool& deepks_setorb,
3636
const int& out_mat_r,
37+
const bool& out_element_info,
3738
const bool& force_flag,
3839
const int& my_rank
3940
);
@@ -44,19 +45,22 @@ class LCAO_Orbitals
4445
const int &lmax_in,
4546
const bool &deepks_setorb, // mohan add 2021-04-25
4647
const int &out_mat_r, // mohan add 2021-04-26
48+
const bool &out_element_info,
4749
const bool &force_flag, // mohan add 2021-05-07
4850
const int &my_rank); // mohan add 2021-04-26
4951

5052
void Read_PAO(
5153
std::ofstream &ofs_in,
5254
const int& it,
55+
const bool &out_element_info,
5356
const bool &force_flag, // mohan add 2021-05-07
5457
const int& my_rank); // mohan add 2021-04-26
5558

5659

5760

5861
void Read_Descriptor(
5962
std::ofstream &ofs_in,
63+
const bool &out_element_info,
6064
const bool &force_flag, // mohan add 2021-05-07
6165
const int &my_rank); //caoyu add 2020-3-16
6266

@@ -119,11 +123,12 @@ class LCAO_Orbitals
119123

120124
void read_orb_file(
121125
std::ofstream &ofs_in,
122-
std::ifstream &ifs,
123-
const int &it,
124-
int &lmax,
125-
int &nchimax,
126+
std::ifstream &ifs,
127+
const int &it,
128+
int &lmax,
129+
int &nchimax,
126130
Numerical_Orbital* ao,
131+
const bool &out_element_info,
127132
const bool &force_flag, // mohan add 2021-05-07
128133
const int &my_rank); //caoyu add 2021-04-26
129134

source/source_basis/module_ao/test/ORB_read_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ void LcaoOrbitalsTest::lcao_read() {
9898
lcao_.dR = dR_;
9999
lcao_.Rmax = Rmax_;
100100

101-
lcao_.Read_Orbitals(ofs_log_, ntype_, lmax_, deepks_setorb_, out_mat_r_,
102-
force_flag_, my_rank_);
101+
lcao_.Read_Orbitals(ofs_log_, ntype_, lmax_, deepks_setorb_, out_mat_r_,
102+
false /* out_element_info */, force_flag_, my_rank_);
103103
}
104104

105105

source/source_basis/module_ao/test/ORB_unittest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ void test_orb::set_orbs()
8383
lcao_rmax,
8484
0,
8585
0,
86+
false, // out_element_info
8687
1, // force
8788
0); // myrank
8889

source/source_basis/module_nao/numerical_radial.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "source_base/global_variable.h"
1212
#include "source_base/math_integral.h"
1313
#include "source_base/spherical_bessel_transformer.h"
14-
#include "source_io/module_parameter/parameter.h"
1514

1615
using ModuleBase::PI;
1716

@@ -154,7 +153,11 @@ void NumericalRadial::build(const int l,
154153
set_icut(for_r_space, !for_r_space);
155154
}
156155

157-
void NumericalRadial::to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm, const int nk_legacy, const double lcao_dk) const
156+
void NumericalRadial::to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm,
157+
const int nk_legacy,
158+
const double lcao_dk,
159+
const bool out_element_info,
160+
const bool cal_force) const
158161
{
159162
#ifdef __DEBUG
160163
assert(rgrid_);
@@ -171,7 +174,7 @@ void NumericalRadial::to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm,
171174

172175
orbital_lm.set_orbital_info(symbol_, itype_, l_, izeta_, std::min(nr_, ircut_+1), rab, rgrid_,
173176
Numerical_Orbital_Lm::Psi_Type::Psi, rvalue_, nk_legacy, lcao_dk,
174-
0.001 /* dr_uniform */, PARAM.inp.out_element_info, true, PARAM.inp.cal_force);
177+
0.001 /* dr_uniform */, out_element_info, true, cal_force);
175178
delete[] rab;
176179
}
177180

source/source_basis/module_nao/numerical_radial.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ class NumericalRadial
109109
* use the k grid of NumericalRadial (which is FFT-compliant with r grid) to initialize
110110
* the k grid of Numerical_Orbital_Lm.
111111
*/
112-
void to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm,
112+
void to_numerical_orbital_lm(Numerical_Orbital_Lm& orbital_lm,
113113
const int nk_legacy = 4005, // equivalent to lcao_ecut = 1600
114-
const double lcao_dk = 0.01) const;
114+
const double lcao_dk = 0.01,
115+
const bool out_element_info = false,
116+
const bool cal_force = false) const;
115117

116118
/**
117119
* @brief Sets a SphericalBesselTransformer.

0 commit comments

Comments
 (0)