diff --git a/source/source_base/math_bspline.h b/source/source_base/math_bspline.h index 5973f04a1c8..1d246d7fe2a 100644 --- a/source/source_base/math_bspline.h +++ b/source/source_base/math_bspline.h @@ -37,7 +37,7 @@ class Bspline int norder; // the order of bezier base; norder >= 0 double Dx; // Dx: the interval of control node double xi; // xi: the starting point - double *bezier; // bezier[n] = Bk[n] + double * bezier = nullptr; // bezier[n] = Bk[n] public: Bspline(); diff --git a/source/source_base/math_chebyshev.h b/source/source_base/math_chebyshev.h index 0b9acf50f08..3d534b911c6 100644 --- a/source/source_base/math_chebyshev.h +++ b/source/source_base/math_chebyshev.h @@ -210,7 +210,7 @@ class Chebyshev std::complex* coefc_cpu = nullptr; //[CPU] expansion coefficient of each order FFTW fftw; // use for fftw - REAL* polytrace; //[CPU] w_n = \sum_i v^+ * T_n(A) * v, only + REAL* polytrace = nullptr; //[CPU] w_n = \sum_i v^+ * T_n(A) * v, only bool getcoef_real; // coef_real has been calculated bool getcoef_complex; // coef_complex has been calculated @@ -248,7 +248,7 @@ class FFTW FFTW(const int norder2_in); ~FFTW(); void execute_fftw(); - double* dcoef; //[norder2] + double* dcoef = nullptr; //[norder2] fftw_complex* ccoef = nullptr; fftw_plan coef_plan; }; @@ -261,7 +261,7 @@ class FFTW FFTW(const int norder2_in); ~FFTW(); void execute_fftw(); - float* dcoef; //[norder2] + float* dcoef = nullptr; //[norder2] fftwf_complex* ccoef = nullptr; fftwf_plan coef_plan; }; diff --git a/source/source_base/mcd.c b/source/source_base/mcd.c index ca5009f468f..cf04c7161a9 100644 --- a/source/source_base/mcd.c +++ b/source/source_base/mcd.c @@ -64,9 +64,9 @@ typedef struct ChunkS #else long long id; // 64bit allocation ID #endif - char *function; //creating function - char *file; //file function is in - void *ptr; //pointer to allocation + char * function = nullptr; //creating function + char * file = nullptr; //file function is in + void * ptr = nullptr; //pointer to allocation struct ChunkS *next, //next chunk (null if nonw) *prev; //previous chunk (null if nonw) }Chunk; @@ -706,7 +706,7 @@ int MCD_sscanf(const char *str,const char *fmt,char*fun,char*file,int line,...) void scan_args(const char *fmt,va_list argptr,char*fun,char*file,int line) { char **ptr; - void *dummy; // clear up the unused warning + void * dummy = nullptr; // clear up the unused warning for(;*fmt;fmt++) { if(*fmt!='%') diff --git a/source/source_base/module_container/base/core/bfc_allocator.h b/source/source_base/module_container/base/core/bfc_allocator.h index 661a0975293..ac1384f2cdd 100644 --- a/source/source_base/module_container/base/core/bfc_allocator.h +++ b/source/source_base/module_container/base/core/bfc_allocator.h @@ -122,7 +122,7 @@ class BFCAllocator : public Allocator { } private: - BFCAllocator* allocator_; // The parent allocator + BFCAllocator* allocator_ = nullptr; // The parent allocator }; using free_chunk_set_t = std::set; diff --git a/source/source_basis/module_ao/ORB_nonlocal.h b/source/source_basis/module_ao/ORB_nonlocal.h index bc5e5776aea..4c4007a796c 100644 --- a/source/source_basis/module_ao/ORB_nonlocal.h +++ b/source/source_basis/module_ao/ORB_nonlocal.h @@ -42,7 +42,7 @@ class Numerical_Nonlocal const int& nproj_in, const Numerical_Nonlocal_Lm* ps_orbital_in); - Numerical_Nonlocal_Lm* Proj; ///< length: nproj(only store radial function ) + Numerical_Nonlocal_Lm* Proj = nullptr; ///< length: nproj(only store radial function ) const double& get_rcut_max() const { return rcut_max; } const int& get_nproj() const { return nproj; } diff --git a/source/source_basis/module_ao/ORB_nonlocal_lm.h b/source/source_basis/module_ao/ORB_nonlocal_lm.h index 11e00d2470c..5ff1378b080 100644 --- a/source/source_basis/module_ao/ORB_nonlocal_lm.h +++ b/source/source_basis/module_ao/ORB_nonlocal_lm.h @@ -85,11 +85,11 @@ class Numerical_Nonlocal_Lm double kcut; double dk; - double* r_radial; //points of r + double* r_radial = nullptr; //points of r double* k_radial = nullptr; double* rab = nullptr; - double* beta_r; // |beta(r) * r> + double* beta_r = nullptr; // |beta(r) * r> double* beta_k = nullptr; }; diff --git a/source/source_basis/module_ao/ORB_read.cpp b/source/source_basis/module_ao/ORB_read.cpp index 50d7e70eb9b..a6a0bb21d5e 100644 --- a/source/source_basis/module_ao/ORB_read.cpp +++ b/source/source_basis/module_ao/ORB_read.cpp @@ -466,10 +466,10 @@ void LCAO_Orbitals::read_orb_file(std::ofstream& ofs_in, // GlobalV::ofs_running { ofs_in << " " << std::setw(12) << count + 1 << std::setw(3) << L << std::setw(3) << N; - double* radial; // radial mesh - double* psi; // radial local orbital + double* radial = nullptr; // radial mesh + double* psi = nullptr; // radial local orbital double* psir; // psi * r - double* rab; // dr + double* rab = nullptr; // dr // set the number of mesh and the interval distance. ofs_in << std::setw(8) << meshr << std::setw(8) << dr; diff --git a/source/source_cell/setup_nonlocal.h b/source/source_cell/setup_nonlocal.h index 0ae8e2df034..4ac214c97e2 100644 --- a/source/source_cell/setup_nonlocal.h +++ b/source/source_cell/setup_nonlocal.h @@ -14,8 +14,8 @@ class InfoNonlocal /// ///NON-LOCAL part for LCAO /// - Numerical_Nonlocal* Beta;/// nonlocal projectors (1-dimension array) - int *nproj; //mohan add 2010-12-19 + Numerical_Nonlocal* Beta = nullptr;/// nonlocal projectors (1-dimension array) + int * nproj = nullptr; //mohan add 2010-12-19 int nprojmax; // mohan add 2010-03-07 double rcutmax_Beta; //caoyu add 2021-05-24 const double& get_rcutmax_Beta(void) const { return rcutmax_Beta; } diff --git a/source/source_esolver/esolver_fp.h b/source/source_esolver/esolver_fp.h index a57af07901d..59fd79a9943 100644 --- a/source/source_esolver/esolver_fp.h +++ b/source/source_esolver/esolver_fp.h @@ -60,8 +60,8 @@ class ESolver_FP: public ESolver //! charge density and potential are defined on dense grids, //! but effective potential needs to be interpolated on smooth grids in order to compute Veff|psi> ModulePW::PW_Basis* pw_rho = nullptr; - ModulePW::PW_Basis* pw_rhod; //! dense grid for USPP - ModulePW::PW_Basis_Big* pw_big; ///< [temp] pw_basis_big class + ModulePW::PW_Basis* pw_rhod = nullptr; //! dense grid for USPP + ModulePW::PW_Basis_Big* pw_big = nullptr; ///< [temp] pw_basis_big class //! parallel for rho grid Parallel_Grid Pgrid; diff --git a/source/source_hsolver/module_genelpa/utils.cpp b/source/source_hsolver/module_genelpa/utils.cpp index 6654c33b9ed..ed79a5790a8 100644 --- a/source/source_hsolver/module_genelpa/utils.cpp +++ b/source/source_hsolver/module_genelpa/utils.cpp @@ -94,7 +94,7 @@ void loadMatrix(const char FileName[], int nFull, double* a, int* desca, int bla if (myid == ROOT_PROC) matrixFile.open(FileName); - double* b; // buffer + double* b = nullptr; // buffer const int MAX_BUFFER_SIZE = 1e9; // max buffer size is 1GB int N = nFull; @@ -179,7 +179,7 @@ void saveMatrix(const char FileName[], int nFull, double* a, int* desca, int bla matrixFile.width(24); } - double* b; // buffer + double* b = nullptr; // buffer const int MAX_BUFFER_SIZE = 1e9; // max buffer size is 1GB int N = nFull; diff --git a/source/source_lcao/force_stress_arrays.h b/source/source_lcao/force_stress_arrays.h index 725665f5c85..6d9b726b2db 100644 --- a/source/source_lcao/force_stress_arrays.h +++ b/source/source_lcao/force_stress_arrays.h @@ -44,7 +44,7 @@ class ForceStressArrays // r_mu - r_nu //---------------------------------------- - double* DH_r;//zhengdy added 2017-07 + double* DH_r = nullptr;//zhengdy added 2017-07 double* stvnl11 = nullptr; double* stvnl12 = nullptr; diff --git a/source/source_lcao/module_ri/ewald_Vq.h b/source/source_lcao/module_ri/ewald_Vq.h index bbd2cff5d4a..4f53a80a704 100644 --- a/source/source_lcao/module_ri/ewald_Vq.h +++ b/source/source_lcao/module_ri/ewald_Vq.h @@ -83,7 +83,7 @@ class Ewald_Vq double ccp_rmesh_times; LRI_CV cv; Gaussian_Abfs gaussian_abfs; - const K_Vectors* p_kv; + const K_Vectors* p_kv = nullptr; std::vector> kvec_c; // std::vector wk; MPI_Comm mpi_comm; diff --git a/source/source_lcao/module_rt/propagator_cn2.cpp b/source/source_lcao/module_rt/propagator_cn2.cpp index 3f85ed26a0f..8563dee8e32 100644 --- a/source/source_lcao/module_rt/propagator_cn2.cpp +++ b/source/source_lcao/module_rt/propagator_cn2.cpp @@ -388,10 +388,10 @@ void Propagator::compute_propagator_cn2_tensor(const int nlocal, // 5. QR Factorization of A (Denominator) int64_t tau_size = m_global + nb; - void* d_tau; + void* d_tau = nullptr; cudaMallocAsync(&d_tau, tau_size * sizeof(std::complex), cublas_res.stream); - int* d_info; + int* d_info = nullptr; cudaMallocAsync(&d_info, sizeof(int), cublas_res.stream); cudaMemsetAsync(d_info, 0, sizeof(int), cublas_res.stream); diff --git a/source/source_md/md_base.h b/source/source_md/md_base.h index c235df3d17e..ccc919ba89c 100644 --- a/source/source_md/md_base.h +++ b/source/source_md/md_base.h @@ -75,7 +75,7 @@ class MD_base int step_; ///< the MD step finished in current calculation int step_rst_; ///< the MD step finished in previous calculations int frozen_freedom_; ///< the fixed freedom of the system - double* allmass; ///< atom mass + double* allmass = nullptr; ///< atom mass ModuleBase::Vector3* pos; ///< atom displacements liuyu modify 2023-03-22 ModuleBase::Vector3* vel; ///< atom velocity ModuleBase::Vector3* ionmbl; ///< atom is frozen or not diff --git a/source/source_md/nhchain.h b/source/source_md/nhchain.h index bdbcf08b2a7..e338f2bb355 100644 --- a/source/source_md/nhchain.h +++ b/source/source_md/nhchain.h @@ -73,10 +73,10 @@ class Nose_Hoover : public MD_base int tdof; ///< particle degree of freedom double t_target=0.0;///< target temperature - double* mass_eta; ///< mass of thermostats coupled with particles - double* eta; ///< position of thermostats coupled with particles - double* v_eta; ///< velocity of thermostats coupled with particles - double* g_eta; ///< acceleration of thermostats coupled with particles + double* mass_eta = nullptr; ///< mass of thermostats coupled with particles + double* eta = nullptr; ///< position of thermostats coupled with particles + double* v_eta = nullptr; ///< velocity of thermostats coupled with particles + double* g_eta = nullptr; ///< acceleration of thermostats coupled with particles int npt_flag; ///< whether NPT ensemble double mass_omega[6]; ///< mass of lattice component @@ -89,10 +89,10 @@ class Nose_Hoover : public MD_base double p_target[6]; ///< target stress components double p_hydro = 0.0; ///< target hydrostatic target pressure double p_current[6] = {0.0}; ///< current stress after coupled - double* mass_peta; ///< mass of thermostats coupled with barostat - double* peta; ///< position of thermostats coupled with barostat - double* v_peta; ///< velocity of thermostats coupled with barostat - double* g_peta; ///< acceleration of thermostats coupled with barostat + double* mass_peta = nullptr; ///< mass of thermostats coupled with barostat + double* peta = nullptr; ///< position of thermostats coupled with barostat + double* v_peta = nullptr; ///< velocity of thermostats coupled with barostat + double* g_peta = nullptr; ///< acceleration of thermostats coupled with barostat double mtk_term=0; ///< mtk correction double md_tfreq; ///< Oscillation frequency, used to determine qmass of thermostats coupled with particles double md_pfirst; ///< Initial pressure diff --git a/source/source_pw/module_pwdft/vl_pw.h b/source/source_pw/module_pwdft/vl_pw.h index afc323d3e5c..0a0f0789dba 100644 --- a/source/source_pw/module_pwdft/vl_pw.h +++ b/source/source_pw/module_pwdft/vl_pw.h @@ -24,11 +24,11 @@ class pseudopot_cell_vl const ModulePW::PW_Basis* rho_basis); ModuleBase::matrix vloc; //(ntype,ngl),the local potential for each atom type(ntype,ngl) - bool *numeric; //[ntype], =true + bool * numeric = nullptr; //[ntype], =true private: - double *zp; // (npsx),the charge of the pseudopotential + double * zp = nullptr; // (npsx),the charge of the pseudopotential void allocate(const UnitCell& ucell, const int ngg); diff --git a/source/source_relax/bfgs_basic.h b/source/source_relax/bfgs_basic.h index 777e6c78eb3..85de10474ac 100644 --- a/source/source_relax/bfgs_basic.h +++ b/source/source_relax/bfgs_basic.h @@ -26,12 +26,12 @@ class BFGS_Basic void reset_hessian(void); void save_bfgs(void); - double* pos; // std::vector containing 3N coordinates of the system ( x ) - double* grad; // std::vector containing 3N components of ( grad( V(x) ) ) - double* move; // pos = pos_p + move. + double* pos = nullptr; // std::vector containing 3N coordinates of the system ( x ) + double* grad = nullptr; // std::vector containing 3N components of ( grad( V(x) ) ) + double* move = nullptr; // pos = pos_p + move. - double* pos_p; // p: previous - double* grad_p; // p: previous + double* pos_p = nullptr; // p: previous + double* grad_p = nullptr; // p: previous double* move_p = nullptr; public: // mohan update 2011-06-12 diff --git a/source/source_relax/lbfgs.h b/source/source_relax/lbfgs.h index 1ad929b7225..94e33fec704 100644 --- a/source/source_relax/lbfgs.h +++ b/source/source_relax/lbfgs.h @@ -48,7 +48,7 @@ class LBFGS double energy; ///< Current system energy double alpha_k; ///< Step size parameter - ModuleESolver::ESolver* solver; ///< Structure solver + ModuleESolver::ESolver* solver = nullptr; ///< Structure solver std::vector steplength;//the length of atoms displacement std::vector> H;//Hessian matrix std::vector force0;//force in previous step