g_density -center shifts coordinates in the wrong direction
in the function center_coords
at line 162 in version 5.0.4
the following code:
rvec_sub(box_center, com, shift);
should be replaced with:
rvec_sub(com, box_center, shift);
otherwise the shifting is incorrect.
To verify, take any system, generate the density profile using g_density option -center, then use trjconv to shift the system 1 nm along z and run g_density -center again. Instead of getting the same result as before, you get a result that is shifted by 2 nm (2 nm because 1 nm for your shift and an extra nm because the shift is corrected in the wrong direction).