Bug in CommBrick::exchange_variable() function causing loss of intermediate results in buf_recv

I believe there is a bug in CommBrick::exchange_variable() [1] (the method follows the algorithm from [2, Fig. 8]) If the conditional statement in the middle of the function is true, it will result in the loss of intermediate results in buf_recv:

comm_brick.cpp:1493:    if (nrecv > maxrecv) grow_recv(nrecv);

I think the following modification should fix it:

modified   src/comm_brick.cpp
@@ -1490,7 +1490,10 @@ int CommBrick::exchange_variable(int n, double *inbuf, double *&outbuf)
       nrecv += nrecv2;
     } else nrecv2 = 0;
-    if (nrecv > maxrecv) grow_recv(nrecv);
+    if (nrecv > maxrecv) {
+      maxrecv = static_cast<int> (BUFFACTOR * nrecv);      
+      memory->grow(buf_recv, maxrecv + bufextra,"comm:buf_recv");
+    }

[1] lammps/comm_brick.cpp at 15116a04567ce7ea2c5a00635d0f421d64f31894 · lammps/lammps · GitHub
[2] Fast Parallel Algorithms for Short-Range Molecular Dynamics,
S. Plimpton, J Comp Phys, 117, 1-19 (1995)

I guess it is a good thing then that this method has not been used anywhere for a long time. :wink:
So the proper fix would be to just remove the method and its variants in derived classes altogether.