From 68e00a60bd8be2c55cb97a3e95156313ff766705 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 15 Jun 2022 12:37:02 -0600 Subject: [PATCH] Fixing rare bug in writing restart files with history --- src/fix_neigh_history.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fix_neigh_history.cpp b/src/fix_neigh_history.cpp index 7413b590a7..613716c9a4 100644 --- a/src/fix_neigh_history.cpp +++ b/src/fix_neigh_history.cpp @@ -351,7 +351,9 @@ void FixNeighHistory::pre_exchange_newton() // 1st loop over neighbor list // calculate npartner for owned+ghost atoms - for (i = 0; i < nall_neigh; i++) npartner[i] = 0; + // Ensure npartner is zeroed across all atoms, nall_neigh can be less than nall + // when writing restarts when comm calls are made but modify->post_neighbor() isn't + for (i = 0; i < MAX(nall_neigh, atom->nall); i++) npartner[i] = 0; tagint *tag = atom->tag; NeighList *list = pair->list; @@ -406,7 +408,7 @@ void FixNeighHistory::pre_exchange_newton() // store partner IDs and values for owned+ghost atoms // re-zero npartner to use as counter - for (i = 0; i < nall_neigh; i++) npartner[i] = 0; + for (i = 0; i < MAX(nall_neigh, atom->nall); i++) npartner[i] = 0; for (ii = 0; ii < inum; ii++) { i = ilist[ii];