avoid 32-bit integer overflow by reordering
This commit is contained in:
@ -201,7 +201,7 @@ void AtomVecSMD::write_data_restricted_to_general()
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
memory->create(x0_hold,nlocal,3,"atomvec:x0_hold");
|
||||
if (nlocal) memcpy(&x0_hold[0][0],&x0[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
if (nlocal) memcpy(&x0_hold[0][0],&x0[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
domain->restricted_to_general_coords(x0[i]);
|
||||
|
||||
@ -221,7 +221,7 @@ void AtomVecSMD::write_data_restore_restricted()
|
||||
if (!x0_hold) return;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
memcpy(&x0[0][0],&x0_hold[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
memcpy(&x0[0][0],&x0_hold[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
memory->destroy(x0_hold);
|
||||
x0_hold = nullptr;
|
||||
}
|
||||
|
||||
@ -771,7 +771,7 @@ void PRD::replicate(int ireplica)
|
||||
|
||||
if (universe->iworld == ireplica) {
|
||||
memcpy(tagall,tag,(nlocal*sizeof(tagint))&MEMCPYMASK);
|
||||
memcpy(xall[0],x[0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
memcpy(xall[0],x[0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
memcpy(imageall,image,(nlocal*sizeof(imageint))&MEMCPYMASK);
|
||||
}
|
||||
|
||||
|
||||
@ -2269,7 +2269,7 @@ void AtomVec::write_data_restricted_to_general()
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
memory->create(x_hold,nlocal,3,"atomvec:x_hold");
|
||||
if (nlocal) memcpy(&x_hold[0][0],&x[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
if (nlocal) memcpy(&x_hold[0][0],&x[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
domain->restricted_to_general_coords(x[i]);
|
||||
|
||||
@ -2290,17 +2290,17 @@ void AtomVec::write_data_restricted_to_general()
|
||||
|
||||
if (array == v) {
|
||||
memory->create(v_hold,nlocal,3,"atomvec:v_hold");
|
||||
if (nlocal) memcpy(&v_hold[0][0],&v[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
if (nlocal) memcpy(&v_hold[0][0],&v[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
domain->restricted_to_general_vector(v[i]);
|
||||
} else if (array == omega) {
|
||||
memory->create(omega_hold,nlocal,3,"atomvec:omega_hold");
|
||||
if (nlocal) memcpy(&omega_hold[0][0],&omega[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
if (nlocal) memcpy(&omega_hold[0][0],&omega[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
domain->restricted_to_general_vector(omega[i]);
|
||||
} else if (array == angmom) {
|
||||
memory->create(angmom_hold,nlocal,3,"atomvec:angmom_hold");
|
||||
if (nlocal) memcpy(&angmom_hold[0][0],&angmom[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
if (nlocal) memcpy(&angmom_hold[0][0],&angmom[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
domain->restricted_to_general_vector(angmom[i]);
|
||||
}
|
||||
@ -2321,7 +2321,7 @@ void AtomVec::write_data_restore_restricted()
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
if (x_hold) {
|
||||
memcpy(&x[0][0],&x_hold[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
memcpy(&x[0][0],&x_hold[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
memory->destroy(x_hold);
|
||||
x_hold = nullptr;
|
||||
}
|
||||
@ -2330,19 +2330,19 @@ void AtomVec::write_data_restore_restricted()
|
||||
// no other write_data Velocities fields are Nx3 double arrays
|
||||
|
||||
if (v_hold) {
|
||||
memcpy(&v[0][0],&v_hold[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
memcpy(&v[0][0],&v_hold[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
memory->destroy(v_hold);
|
||||
v_hold = nullptr;
|
||||
}
|
||||
|
||||
if (omega_hold) {
|
||||
memcpy(&atom->omega[0][0],&omega_hold[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
memcpy(&atom->omega[0][0],&omega_hold[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
memory->destroy(omega_hold);
|
||||
omega_hold = nullptr;
|
||||
}
|
||||
|
||||
if (angmom_hold) {
|
||||
memcpy(&atom->angmom[0][0],&angmom_hold[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
memcpy(&atom->angmom[0][0],&angmom_hold[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
memory->destroy(angmom_hold);
|
||||
angmom_hold = nullptr;
|
||||
}
|
||||
|
||||
@ -409,8 +409,8 @@ void Dump::write()
|
||||
int nlocal = atom->nlocal;
|
||||
if (nlocal > maxpbc) pbc_allocate();
|
||||
if (nlocal) {
|
||||
memcpy(&xpbc[0][0],&atom->x[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
memcpy(&vpbc[0][0],&atom->v[0][0],(3*nlocal*sizeof(double))&MEMCPYMASK);
|
||||
memcpy(&xpbc[0][0],&atom->x[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
memcpy(&vpbc[0][0],&atom->v[0][0],(sizeof(double)*3*nlocal)&MEMCPYMASK);
|
||||
memcpy(imagepbc,atom->image,(nlocal*sizeof(imageint))&MEMCPYMASK);
|
||||
}
|
||||
xhold = atom->x;
|
||||
|
||||
Reference in New Issue
Block a user