Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
744c5b5
init variable and fix memory leak bug in module_base
A-006 Dec 24, 2024
8c4f7dc
fix uninit member var in module_basis
A-006 Dec 24, 2024
e9f4dd9
chang logic bug and uninit memeber value in the module cell
A-006 Dec 24, 2024
bf44f6a
chang logic bug and uninit memeber value in the module_elecstate
A-006 Dec 24, 2024
26d168f
chang logic bug and uninit memeber value in the module_eslover
A-006 Dec 24, 2024
872ea69
chang memory leak risk and uninit memeber value in the module_hamilt_…
A-006 Dec 24, 2024
f766db6
chang uninit memeber value in the module_hamilt_lcao
A-006 Dec 24, 2024
8b2776e
chang uninit memeber value in the module_hamilt_pwdft
A-006 Dec 24, 2024
7f9461a
fix in klist
A-006 Dec 24, 2024
78a3697
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 24, 2024
5c416f5
fix useless assert
A-006 Dec 24, 2024
b27dd63
revert change in read_pp_upf100.cpp
A-006 Dec 25, 2024
af8000c
change uninit memeber value in module_hamilt_pw
A-006 Dec 25, 2024
7b2d38c
change uninit memeber value in module_hsolver
A-006 Dec 25, 2024
3a0b270
change uninit memeber value in module_io
A-006 Dec 25, 2024
70a93c2
change uninit memeber value in module_md and module_relax
A-006 Dec 25, 2024
cde37f0
Merge branch 'develop' into init
A-006 Dec 25, 2024
a9617a5
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 25, 2024
4a90f3c
Merge branch 'develop' into init
A-006 Dec 25, 2024
b5c3ac2
update nnr init data
A-006 Dec 26, 2024
bcf89ff
fix uninit member value
A-006 Dec 27, 2024
34a92ad
Merge branch 'develop' into init
A-006 Dec 27, 2024
6d04a65
Merge branch 'develop' into init
A-006 Dec 27, 2024
d88f6f3
update value in elecstate_energy.cpp
A-006 Dec 29, 2024
20267ef
add init parameter for construct in sto_func
A-006 Dec 29, 2024
9237bd2
add value in the construct file
A-006 Dec 29, 2024
088428c
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 29, 2024
8329a97
change magnetism.cpp
A-006 Dec 29, 2024
3d98185
Merge branch 'develop' into init
A-006 Dec 29, 2024
e6ecce4
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 29, 2024
60efe2d
modify logic of elecstate_energy.cpp
A-006 Dec 30, 2024
1969b6a
Merge branch 'develop' into init
A-006 Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions source/module_base/intarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,14 @@ class IntArray
}

private:
int size;
int dim;
int bound1, bound2, bound3, bound4, bound5, bound6;
int size=0;
int dim=0;
int bound1=0;
int bound2=0;
int bound3=0;
int bound4=0;
int bound5=0;
int bound6=0;
static int arrayCount;
void freemem();
};
Expand Down
14 changes: 7 additions & 7 deletions source/module_base/inverse_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class Inverse_Matrix_Complex
void init( const int &dim_in);

private:
int dim;
double *e;
int lwork;
std::complex<double> *work2;
double* rwork;
int info;
bool allocate; //mohan add 2012-04-02
int dim=0;
double *e=nullptr;
int lwork=0;
std::complex<double> *work2=nullptr;
double* rwork=nullptr;
int info=0;
bool allocate=false; //mohan add 2012-04-02

ModuleBase::ComplexMatrix EA;
};
Expand Down
1 change: 1 addition & 0 deletions source/module_base/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ void Memory::print_all(std::ofstream &ofs)
#if defined(__CUDA) || defined(__ROCM)
if(!init_flag_gpu)
{
delete[] print_flag;
return;
}

Expand Down
2 changes: 2 additions & 0 deletions source/module_basis/module_ao/ORB_nonlocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Numerical_Nonlocal::Numerical_Nonlocal()
//question remains
this->type = 0;
this->lmax = 0;
this->rcut_max = 0.0;
this->Proj = new Numerical_Nonlocal_Lm[1];
this->nproj = -1;
//zhengdy-soc, for optimize nonlocal part
Expand Down Expand Up @@ -49,6 +50,7 @@ void Numerical_Nonlocal::set_type_info
//----------------------------------------------------------
//only store radial function
delete[] Proj;
this->Proj = nullptr;
this->Proj = new Numerical_Nonlocal_Lm[this->nproj];

for (int p1=0; p1<nproj; p1++)
Expand Down
8 changes: 4 additions & 4 deletions source/module_basis/module_ao/ORB_nonlocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ class Numerical_Nonlocal

Numerical_Nonlocal_Lm* Proj; ///< length: nproj(only store radial function )

const double& get_rcut_max(void) const { return rcut_max; }
const double& get_rcut_max() const { return rcut_max; }
const int& get_nproj() const { return nproj; }

private:

std::string label; /// <element label
std::string label=""; /// <element label

int type; ///< element index

int lmax; ///< max value of L angular momentum

double rcut_max;
double rcut_max=0.0;

std::string type_ps; ///<local or nonlocal
std::string type_ps=""; ///<local or nonlocal

int nproj;

Expand Down
7 changes: 4 additions & 3 deletions source/module_basis/module_ao/ORB_nonlocal_lm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Numerical_Nonlocal_Lm::Numerical_Nonlocal_Lm()
label = "";
index_atom_type = 0;
angular_momentum_l = 0;
index_proj = 0;

nr = 1;
nk = 1;
Expand All @@ -34,7 +35,7 @@ Numerical_Nonlocal_Lm::~Numerical_Nonlocal_Lm()
this->freemem();
}

void Numerical_Nonlocal_Lm::renew(void)
void Numerical_Nonlocal_Lm::renew()
{
assert(nr_uniform>0);
assert(nr>0);
Expand All @@ -55,7 +56,7 @@ void Numerical_Nonlocal_Lm::renew(void)
ModuleBase::GlobalFunc::ZEROS(beta_k, nk);
}

void Numerical_Nonlocal_Lm::freemem(void)
void Numerical_Nonlocal_Lm::freemem()
{
delete[] this->r_radial;
delete[] this->rab;
Expand Down Expand Up @@ -246,7 +247,7 @@ void Numerical_Nonlocal_Lm::extra_uniform(const double &dr_uniform_in)
}
*/

void Numerical_Nonlocal_Lm::get_kradial(void)
void Numerical_Nonlocal_Lm::get_kradial()
{
//ModuleBase::TITLE("Numerical_Nonlocal_Lm","get_kradial");
double *jl = new double[nr];
Expand Down
18 changes: 13 additions & 5 deletions source/module_basis/module_ao/parallel_orbitals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@

Parallel_Orbitals::Parallel_Orbitals()
{
loc_sizes = nullptr;

this->loc_sizes = nullptr;
// in multi-k, 2D-block-division variables for FT (R<->k)
nnr = 1;
nlocdim = nullptr;
nlocstart = nullptr;
this->nlocdim = nullptr;
this->nlocstart = nullptr;
this->nnr = 1;
this->ncol_bands = 0;
this->nrow_bands=0;
this->nloc_wfc=0;
this->nloc_Eij=0;
this->lastband_in_proc=0;
this->lastband_number=0;
this->loc_size=0;
this->nbands = 0;

}

Parallel_Orbitals::~Parallel_Orbitals()
Expand Down
4 changes: 2 additions & 2 deletions source/module_basis/module_ao/parallel_orbitals.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Parallel_Orbitals : public Parallel_2D
/// number of elements(basis-pairs) in this processon
/// on all adjacent atoms-pairs(2D division)
///---------------------------------------
int nnr;
int nnr=1;
int *nlocdim;
int *nlocstart;

Expand Down Expand Up @@ -80,7 +80,7 @@ class Parallel_Orbitals : public Parallel_2D

int get_nbands() const;

int nbands = 0;
int nbands;

/**
* @brief gather global indexes of orbitals in this processor
Expand Down
10 changes: 6 additions & 4 deletions source/module_basis/module_pw/pw_basis_big.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ class PW_Basis_Big : public PW_Basis_Sup
bxyz = bx * by * bz;
}
int bx = 1, by = 1, bz = 1, bxyz = 1;
int nbx, nby, nbz;
int nbzp;
int nbxx;
int nbzp_start;
int nbx=0;
int nby=0;
int nbz=0;
int nbzp=0;
int nbxx=0;
int nbzp_start=0;

void autoset_big_cell_size(int& b_size, const int& nc_size, const int nproc = 0)
{
Expand Down
6 changes: 3 additions & 3 deletions source/module_basis/module_pw/pw_basis_k.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ class PW_Basis_K : public PW_Basis
double *gk2=nullptr; // modulus (G+K)^2 of G vectors [npwk_max*nks]

// liuyu add 2023-09-06
double erf_ecut; // the value of the constant energy cutoff
double erf_height; // the height of the energy step for reciprocal vectors
double erf_sigma; // the width of the energy step for reciprocal vectors
double erf_ecut=0.0; // the value of the constant energy cutoff
double erf_height=0.0; // the height of the energy step for reciprocal vectors
double erf_sigma=0.0; // the width of the energy step for reciprocal vectors

//collect gdirect, gcar, gg
void collect_local_pw(const double& erf_ecut_in = 0.0,
Expand Down
12 changes: 9 additions & 3 deletions source/module_basis/module_pw/pw_basis_k_big.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ class PW_Basis_K_Big: public PW_Basis_K
by = by_in;
bz = bz_in;
}
int bx,by,bz;
int nbx, nby, nbz;
int bx=0;
int by=0;
int bz=0;
int nbx=0;
int nby=0;
int nbz=0;

virtual void distribute_r()
{
bx = (bx == 0) ? 2 : bx;
Expand All @@ -51,7 +56,8 @@ class PW_Basis_K_Big: public PW_Basis_K
for(int ip = 0 ; ip < this->poolnproc ; ++ip)
{
this->numz[ip] = npbz*this->bz;
if(ip < modbz) this->numz[ip]+=this->bz;
if(ip < modbz) { this->numz[ip]+=this->bz;
}
if(ip < this->poolnproc - 1) this->startz[ip+1] = this->startz[ip] + numz[ip];
if(ip == this->poolrank)
{
Expand Down
21 changes: 3 additions & 18 deletions source/module_cell/klist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,18 @@

K_Vectors::K_Vectors()
{
#ifdef _MCD_CHECK
FILE* out;
out = fopen("1_Memory", "w");
if (out == NULL)
{
std::cout << "\n Can't open file!";
ModuleBase::QUIT();
}
_MCD_RealTimeLog(out);
_MCD_MemStatLog(out);
// showMemStats();
#endif

nspin = 0; // default spin.
kc_done = false;
kd_done = false;

nkstot_full = 0;
nks = 0;
nkstot = 0;
k_nkstot = 0; // LiuXh add 20180619
}

K_Vectors::~K_Vectors()
{
// ModuleBase::TITLE("K_Vectors","~K_Vectors");
#ifdef _MCD_CHECK
showMemStats();
#endif
}

int K_Vectors::get_ik_global(const int& ik, const int& nkstot)
Expand Down Expand Up @@ -963,7 +947,8 @@ void K_Vectors::ibz_kpoint(const ModuleSymmetry::Symmetry& symm,
break;
}
}
if (exist_number != -1) break;
if (exist_number != -1) { break;
}
}
this->kstars[exist_number].insert(std::make_pair(isym, kvec_d[i]));
}
Expand Down
4 changes: 2 additions & 2 deletions source/module_cell/klist.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class K_Vectors
std::vector<int> ngk; /// ngk, number of plane waves for each k point
std::vector<int> isk; /// distinguish spin up and down k points

int nmp[3]; /// Number of Monhorst-Pack
int nmp[3]={0}; /// Number of Monhorst-Pack
std::vector<int> kl_segids; /// index of kline segment

/// @brief equal k points to each ibz-kpont, corresponding to a certain symmetry operations.
Expand Down Expand Up @@ -163,7 +163,7 @@ class K_Vectors
int nspin;
bool kc_done;
bool kd_done;
double koffset[3]; // used only in automatic k-points.
double koffset[3]={0.0}; // used only in automatic k-points.
std::string k_kword; // LiuXh add 20180619
int k_nkstot; // LiuXh add 20180619
bool is_mp = false; // Monkhorst-Pack
Expand Down
3 changes: 3 additions & 0 deletions source/module_cell/module_neighbor/sltk_atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ FAtom::FAtom()
z = 0.0;
type = 0;
natom = 0;
cell_x = 0;
cell_y = 0;
cell_z = 0;
}
38 changes: 19 additions & 19 deletions source/module_cell/module_neighbor/sltk_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ class Grid
void init(std::ofstream& ofs, const UnitCell& ucell, const double radius_in, const bool boundary = true);

// Data
bool pbc; // When pbc is set to false, periodic boundary conditions are explicitly ignored.
double sradius2; // searching radius squared (unit:lat0)
double sradius; // searching radius (unit:lat0)
bool pbc=false; // When pbc is set to false, periodic boundary conditions are explicitly ignored.
double sradius2=0.0; // searching radius squared (unit:lat0)
double sradius=0.0; // searching radius (unit:lat0)

// coordinate range of the input atom (unit:lat0)
double x_min;
double y_min;
double z_min;
double x_max;
double y_max;
double z_max;
double x_min=0.0;
double y_min=0.0;
double z_min=0.0;
double x_max=0.0;
double y_max=0.0;
double z_max=0.0;

// The algorithm for searching neighboring atoms uses a "box" partitioning method.
// Each box has an edge length of sradius, and the number of boxes in each direction is recorded here.
double box_edge_length;
int box_nx;
int box_ny;
int box_nz;
double box_edge_length=0.0;
int box_nx=0;
int box_ny=0;
int box_nz=0;

void getBox(int& bx, int& by, int& bz, const double& x, const double& y, const double& z)
{
Expand Down Expand Up @@ -104,12 +104,12 @@ class Grid
void Construct_Adjacent_final(const FAtom& fatom1, FAtom* fatom2);

void Check_Expand_Condition(const UnitCell& ucell);
int glayerX;
int glayerX_minus;
int glayerY;
int glayerY_minus;
int glayerZ;
int glayerZ_minus;
int glayerX=0;
int glayerX_minus=0;
int glayerY=0;
int glayerY_minus=0;
int glayerZ=0;
int glayerZ_minus=0;
};

#endif
8 changes: 4 additions & 4 deletions source/module_cell/module_paw/paw_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void Paw_Element::read_paw_xml(std::string filename)
this->lstate[istate] = this->extract_int(line,"l=");
lmax = std::max(lmax, lstate[istate]);

int pos = line.find("f=");
size_t pos = line.find("f=");
if(pos!=std::string::npos)
{
this->lstate_occ[istate] = this->extract_double(line,"f=");
Expand Down Expand Up @@ -178,7 +178,7 @@ std::string Paw_Element::scan_file(std::ifstream &ifs, std::string pattern)

double Paw_Element::extract_double(std::string line, std::string key)
{
int index = line.find(key);
size_t index = line.find(key);
if (index != std::string::npos)
{
std::stringstream tmp;
Expand All @@ -198,7 +198,7 @@ double Paw_Element::extract_double(std::string line, std::string key)

std::string Paw_Element::extract_string(std::string line, std::string key)
{
int index = line.find(key);
size_t index = line.find(key);
if (index != std::string::npos)
{
std::stringstream tmp;
Expand All @@ -218,7 +218,7 @@ std::string Paw_Element::extract_string(std::string line, std::string key)

int Paw_Element::extract_int(std::string line, std::string key)
{
int index = line.find(key);
size_t index = line.find(key);
if (index != std::string::npos)
{
std::stringstream tmp;
Expand Down
Loading
Loading