<div><span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">I have made it. </span></div><div><span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><span style="background-color:rgb(255,255,255)"><font color="#222222" face="arial, sans-serif">Dear Dr. Costescu, your comments have been most helpful, especially about iprod() and gmx_invsqrt(). I did not want to get deep into the code, and these parts were most crucial. Apparently  bond_angle() also returns the bond vectors r_ij and r_jk, so I was able to calculate the length of r_ij easily using these functions. It is enough to only check r_ij because I will pay attention to the atom order in my topology. After all, this is a hack for a very limited scenario. I also followed your advice and included rest of the for loop in my if clause, it looks safe as far as I understand. </font></span></div>
<div><span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">The whole thing took 3 lines and works like a charm. I think it is even fairly efficient. I have not yet tried it with domain decomposition, but according to Dr. Hess, it should be fine using -noddcheck. </span></div>
<div><span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><br></span></div><div><font color="#222222" face="arial, sans-serif">Instead of using a fancy IDE, I found this website ( </font><a href="http://fossies.org/unix/privat/gromacs-4.5.5.tar.gz/dox/bondfree_8c_source.html#l02440">http://fossies.org/unix/privat/gromacs-4.5.5.tar.gz/dox/bondfree_8c_source.html</a> <span style="color:rgb(34,34,34);font-family:arial,sans-serif">) that provides a fancy code explorer. This made things much easier.</span></div>
<div><span style="color:rgb(34,34,34);font-family:arial,sans-serif"><br></span></div><div><font color="#222222" face="arial, sans-serif">My plan B was to port the whole thing to LAMMPS even before Dr. Jewett proposed it, but I was trying to avoid that as I am used to GROMACS and wouldn&#39;t want to give up any of the performance. I was overwhelmed by the code at first, but thanks to your support, </font><span style="color:rgb(34,34,34);font-family:arial,sans-serif">this has been a very rewarding/educative process. Thanks to you all. </span></div>
<div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">Cheers</font></div><div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">Murat</font></div>