+C if (SELFGUIDE.gt.0) then
+C distance=0.0
+C do j=1,3
+C vec_afm(j)=c(j,afmend)-c(j,afmbeg)
+C distance=distance+vec_afm(j)**2
+C enddo
+C distance=dsqrt(distance)
+C do j=1,3
+C d_t_work_new(j+(afmbeg-1)*3)=-velAFMconst*vec_afm(j)/distance
+C d_t_work_new(j+(afmend-1)*3)=velAFMconst*vec_afm(j)/distance
+C write(iout,*) "myvel",d_t_work_new(j+(afmbeg-1)*3),
+C & d_t_work_new(j+(afmend-1)*3)
+C enddo
+
+C endif
+