Skip to content

Commit d11522d

Browse files
committed
Merge branch 'develop' of github.com:deepmodeling/abacus-develop into develop
2 parents 1a80729 + d295d5d commit d11522d

File tree

7 files changed

+29
-27
lines changed

7 files changed

+29
-27
lines changed

source/module_cell/atom_spec.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Atom::Atom()
1515
taud = new ModuleBase::Vector3<double>[1];
1616
vel = new ModuleBase::Vector3<double>[1];
1717
mag = new double[1];
18+
angle1 = new double[1];
19+
angle2 = new double[1];
20+
m_loc_ = new ModuleBase::Vector3<double>[1];
1821
l_nchi = new int[1];
1922
iw2l = new int[1];
2023
iw2n = new int[1];
@@ -29,6 +32,9 @@ Atom::~Atom()
2932
delete[] taud;
3033
delete[] vel;
3134
delete[] mag;
35+
delete[] angle1;
36+
delete[] angle2;
37+
delete[] m_loc_;
3238
delete[] l_nchi;
3339
delete[] iw2l;
3440
delete[] iw2n;
@@ -137,6 +143,9 @@ void Atom::bcast_atom(void)
137143
delete[] taud;
138144
delete[] vel;
139145
delete[] mag;
146+
delete[] angle1;
147+
delete[] angle2;
148+
delete[] m_loc_;
140149
tau = new ModuleBase::Vector3<double>[na];
141150
taud = new ModuleBase::Vector3<double>[na];
142151
vel = new ModuleBase::Vector3<double>[na];

source/module_cell/read_atoms.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,9 @@ bool UnitCell_pseudo::read_atom_positions(std::ifstream &ifpos, std::ofstream &o
570570
delete[] atoms[it].vel;
571571
delete[] atoms[it].mbl;
572572
delete[] atoms[it].mag;
573+
delete[] atoms[it].angle1;
574+
delete[] atoms[it].angle2;
575+
delete[] atoms[it].m_loc_;
573576
atoms[it].tau = new ModuleBase::Vector3<double>[na];
574577
atoms[it].taud = new ModuleBase::Vector3<double>[na];
575578
atoms[it].vel = new ModuleBase::Vector3<double>[na];

source/module_cell/unitcell_pseudo.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -695,24 +695,11 @@ void UnitCell_pseudo::setup_cell_after_vc(std::ofstream &log)
695695
for(int ia =0;ia< atom->na;ia++)
696696
{
697697
atom->tau[ia] = atom->taud[ia] * latvec;
698-
/*
699-
#ifdef __MPI
700-
Parallel_Common::bcast_double( atom->tau[ia].x );
701-
Parallel_Common::bcast_double( atom->tau[ia].y );
702-
Parallel_Common::bcast_double( atom->tau[ia].z );
703-
Parallel_Common::bcast_double( atom->taud[ia].x );
704-
Parallel_Common::bcast_double( atom->taud[ia].y );
705-
Parallel_Common::bcast_double( atom->taud[ia].z );
706-
#endif
707-
*/
708698
}
709699
}
700+
710701
#ifdef __MPI
711-
MPI_Barrier(MPI_COMM_WORLD);
712-
for (int i=0;i<ntype;i++)
713-
{
714-
atoms[i].bcast_atom(); // bcast tau array
715-
}
702+
this->bcast_unitcell();
716703
#endif
717704

718705
log << std::endl;

source/module_gint/gint_tools.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace Gint_Tools
3939
const int jby,
4040
const int kbz)
4141
{
42-
int *vindex = (int*)malloc(GlobalC::bigpw->bxyz*sizeof(int));
42+
int *vindex = new int[GlobalC::bigpw->bxyz];
4343
int bindex=0;
4444
// z is the fastest,
4545
// ipart can be obtained by using a previously stored array
@@ -71,12 +71,12 @@ namespace Gint_Tools
7171
{
7272
// set the index for obtaining local potentials
7373
int* vindex = Gint_Tools::get_vindex(ncyz, ibx, jby, kbz);
74-
double *vldr3 = (double*)malloc(GlobalC::bigpw->bxyz*sizeof(double));
74+
double *vldr3 = new double[GlobalC::bigpw->bxyz];
7575
for(int ib=0; ib<GlobalC::bigpw->bxyz; ib++)
7676
{
7777
vldr3[ib]=vlocal[vindex[ib]] * dv;
7878
}
79-
free(vindex); vindex=nullptr;
79+
delete[] vindex;
8080
return vldr3;
8181
}
8282

@@ -88,12 +88,12 @@ namespace Gint_Tools
8888
{
8989
// set the index for obtaining local potentials
9090
int* vindex = Gint_Tools::get_vindex(start_ind, ncyz);
91-
double *vldr3 = (double*)malloc(GlobalC::bigpw->bxyz*sizeof(double));
91+
double *vldr3 = new double[GlobalC::bigpw->bxyz];
9292
for(int ib=0; ib<GlobalC::bigpw->bxyz; ib++)
9393
{
9494
vldr3[ib]=vlocal[vindex[ib]] * dv;
9595
}
96-
free(vindex); vindex=nullptr;
96+
delete[] vindex;
9797
return vldr3;
9898
}
9999

source/module_gint/gint_tools.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ namespace Gint_Tools
243243
template<typename T>
244244
Array_Pool<T>::Array_Pool(const int nr, const int nc) // Attention: uninitialized
245245
{
246-
ptr_1D = (T*)malloc(nr*nc*sizeof(T));
247-
ptr_2D = (T**)malloc(nr*sizeof(T*));
246+
ptr_1D = new T[nr*nc];
247+
ptr_2D = new T*[nr];
248248
for (int ir=0; ir<nr; ++ir)
249249
ptr_2D[ir] = &ptr_1D[ir*nc];
250250
}
@@ -254,15 +254,15 @@ namespace Gint_Tools
254254
{
255255
ptr_1D = array.ptr_1D;
256256
ptr_2D = array.ptr_2D;
257-
free(array.ptr_2D); array.ptr_2D=nullptr;
258-
free(array.ptr_1D); array.ptr_1D=nullptr;
257+
delete[] array.ptr_2D;
258+
delete[] array.ptr_1D;
259259
}
260260

261261
template<typename T>
262262
Array_Pool<T>::~Array_Pool()
263263
{
264-
free(ptr_2D);
265-
free(ptr_1D);
264+
delete[] ptr_2D;
265+
delete[] ptr_1D;
266266
}
267267
}
268268

source/module_md/MSST.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ void MSST::rescale(double volume)
240240
ucell.latvec.e11 *= dilation[0];
241241
ucell.latvec.e22 *= dilation[1];
242242
ucell.latvec.e33 *= dilation[2];
243+
ucell.a1 *= dilation[0];
244+
ucell.a2 *= dilation[1];
245+
ucell.a3 *= dilation[2];
243246

244247
ucell.setup_cell_after_vc(GlobalV::ofs_running);
245248
MD_func::InitPos(ucell, pos);

tests/deepks/Autotest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ repo="$(realpath ..)/"
159159
if [ "$sanitize" == true ]; then
160160
echo "Testing with Address Sanitizer..."
161161
mkdir ../html
162-
echo -e "# Address Sanitizer Diagnostics\n" > ../html/README.md
162+
echo -e "# Address Sanitizer Diagnostics\n" >> ../html/README.md
163163
report=$(realpath ../html/README.md)
164164
fi
165165

0 commit comments

Comments
 (0)