Pressure (Virial) calculation problem

Dear LAMMPS users,

I am trying to calculate the system pressure based on the virial theorem as compute_presssure does.
By comparing the virial part (force f dot location x), my calculation deviate much from the result in compute_pressure.cpp, which is from the function of virial_fdotr_compute() in pair.cpp.
I used the same mathod in virial_fdotr_compute(), which sums f[i][0-2] dot x[i][0-2] for owned and ghost atoms.
I checked the differences by decoupling force and location, and found the location x[i][0-2] are the same, but the forces are not.
I read through the developer guide from LAMMPS, and found that after the force calculation by pair->compute(), there is comm->reverse_comm(), which maps forces on ghost atoms back to owned atoms.
Because the virial from LAMMPS is calculated during pair->compute(), before comm->reverse_comm(), and I am trying to calculate virial during fix->post_force(), after comm->reverse_comm().
I suppose the comm->reverse_comm() process makes the differences in calculating virial. But I don’t know how it works and how I should solve that if this process results in the differences.

Thanks in advance for any advice and comments regarding this issue.

Best,
Xiao Jia

If you wait to compute F dot X until after
the reverse_comm, then all forces have been
summed back to owned atoms. So the
effects (on the virial) of ghost atoms are lost.
So you can;t compute it as F dot X at that
point. Which is why LAMMPS does the F dot X
including ghost atoms before the reverse_comm.

Steve