anchor.diff:    else
   
       if(x < zero) then ! Crystal hit from below
  -!      write(*,*) 'Crystal hit from below'
  +!      write(*,*) 'Crystal potentially hit from below'
   !      write(*,*) 'CHECK', x
         xp_tangent = sqrt((-(two*x)*c_rcurv + x**2)/c_rcurv**2)
   !      write(*,*) 'tangent', xp_tangent, xp
       else ! Crystal hit from above
  +!      write(*,*) 'Crystal potentially hit from above'
   !      write(*,*) 'CHECK', x
         xp_tangent = asin_mb((c_rcurv*(one - c_cBend) - x)/sqrt(((two*c_rcurv)*(c_rcurv - x))*(one - c_cBend) + x**2))
   !      write(*,*) 'tangent', xp_tangent, xp
  
positive.code: !  write(*,*) "r", r
  
    ! MISCUT third step: F coordinates on crystal exit face
    A_F = tan_mb(cry_bend)**2 + one
    B_F = -two*tan_mb(cry_bend)**2*c_rcurv + two*tan_mb(cry_bend)*s_P -two*x_P
    C_F = tan_mb(cry_bend)**2*c_rcurv**2 - two*tan_mb(cry_bend)*s_P*c_rcurv + s_P**2 + x_P**2 - r**2
  
    x_F = (-B_F-sqrt(B_F**2-four*A_F*C_F))/(two*A_F)
    s_F = -tan_mb(cry_bend)*(x_F-c_rcurv)
  !  write(*,*) "F", s_F, x_F
  
    if(x_F >= x_K .and. x_F <= x_M .and. s_F >= s_M .and. s_F <= s_K) then
  !    write(*,*) "F on exit face"
      ! MISCUT No additional steps required
    else
  !    write(*,*) "F NOT on exit face"
  
  
negative.code: 
      else
  
  !      write(*,*) 'Crystal NOT actually hit'
        s = c_rcurv*sin_mb(cry_length/c_rcurv)
        x = x + s*xp
        z = z + s*zp
  