LAMMPS get stuck when communicating information between local atoms and ghost atoms

Hi all,
Recently I’m implementing a new force field into LAMMPS. In this force field, one needs to communicate the information from local atoms to the ghost atoms. So I use functions pack_forward_comm and unpack_forward_comm to realize it, which is similar to that in pair eam.

When I’m testing the potential, I found some problem, which is as follows:
When I use 1 or 2 cores to run the simulation, everything is fine and the results are correct. However, when I use 4 or more cores to run the simulation, LAMMPS got stuck, i.e., there is no output and no error message.

So I start to debug my codes and try to find the problem, I found LAMMPS get stuck at the following command in “compute” function:
comm->forward_comm_pair(this);
More specifically, the codes get stuck at the function: pack_forward_comm and never reach function unpack_forward_comm.

According to the above information, I guess there are some bugs or inconsistency in my codes when communicating information between local and ghost atoms with multiple CPUs. However, due to my limited knowledge of the structure of LAMMPS, I don’t know how to solve it.

Could anyone help me and give me some hints? Any inputs will be grateful.
Thank you in advance!

Best,
Huang

Greetings, pack forward comm should just have a loop where you pack the buffer. are the loop conditions and the variables declared in the pack routine correct? also did you make sure to specify the correct sizes in the variables comm_forward and comm_reverse that are declared in the constructor?

Thanks for the quick answer.
Yes, the loop and variables, as well as the size for comm_forward are defined correctly. Otherwise, LAMMPS cannot run simulations correctly when using 1 or 2 CPUs. (When I use 1 or 2 cores to run the simulation, everything is fine and the results are correct.)
In my force field, the communication from ghost atom to local atom is not needed, so I didn’t define comm_reverse.

Best,
Huang