avoid segfault in Special::angle_trim() if only angles or only dihedrals are defined

This commit is contained in:
Axel Kohlmeyer
2019-04-04 09:13:18 -04:00
parent 8c03f51020
commit 88d160f86e

View File

@ -821,6 +821,7 @@ void Special::angle_trim()
int nsend = 0;
for (i = 0; i < nlocal; i++) {
if (num_angle) {
for (j = 0; j < num_angle[i]; j++) {
if (tag[i] != angle_atom2[i][j]) continue;
m = atom->map(angle_atom1[i][j]);
@ -828,6 +829,9 @@ void Special::angle_trim()
m = atom->map(angle_atom3[i][j]);
if (m < 0 || m >= nlocal) nsend++;
}
}
if (num_dihedral) {
for (j = 0; j < num_dihedral[i]; j++) {
if (tag[i] != dihedral_atom2[i][j]) continue;
m = atom->map(dihedral_atom1[i][j]);
@ -838,6 +842,7 @@ void Special::angle_trim()
if (m < 0 || m >= nlocal) nsend++;
}
}
}
int *proclist;
memory->create(proclist,nsend,"special:proclist");
@ -852,6 +857,7 @@ void Special::angle_trim()
nsend = 0;
for (i = 0; i < nlocal; i++) {
if (num_angle) {
for (j = 0; j < num_angle[i]; j++) {
if (tag[i] != angle_atom2[i][j]) continue;
@ -871,7 +877,9 @@ void Special::angle_trim()
nsend++;
}
}
}
if (num_dihedral) {
for (j = 0; j < num_dihedral[i]; j++) {
if (tag[i] != dihedral_atom2[i][j]) continue;
@ -900,6 +908,7 @@ void Special::angle_trim()
}
}
}
}
// perform rendezvous operation
@ -932,6 +941,7 @@ void Special::angle_trim()
// output datums = pairs of atoms that are 1-3 neighbors
for (i = 0; i < nlocal; i++) {
if (num_angle) {
for (j = 0; j < num_angle[i]; j++) {
if (tag[i] != angle_atom2[i][j]) continue;
@ -953,7 +963,9 @@ void Special::angle_trim()
}
}
}
}
if (num_dihedral) {
for (j = 0; j < num_dihedral[i]; j++) {
if (tag[i] != dihedral_atom2[i][j]) continue;
@ -985,6 +997,7 @@ void Special::angle_trim()
}
}
}
}
for (m = 0; m < nreturn; m++) {
i = atom->map(outbuf[m].atomID);