anchor.diff:        A_F = alpha_F**2 + one
         B_F = two*alpha_F*beta_F - two*c_rcurv
         C_F = beta_F**2 -c_xmax*(c_xmax-two*c_rcurv)
  +      write(*,*) alpha_F, beta_F, A_F, B_F, C_F
       endif
       
       x_F = (-B_F-sqrt(B_F**2-four*A_F*C_F))/(two*A_F)
       s_F = alpha_F*x_F + beta_F
  -
  +    write(*,*) B_F**2, A_F*C_F, four*A_F*C_F, B_F**2-four*A_F*C_F
  +    write(*,*) x_F, s_F
  +    
     endif
   
     ! MISCUT fourth step: deflection and length
     a = sqrt(s_F**2+(x-x_F)**2)
  -  tchan = acos_mb((two*r**2-a**2)/(two*r**2))
  -  L_chan = r*tchan
  -  write(*,*) "Results", tchan, L_chan
  +  tdefl = asin_mb((s_f-s_P)/r)
  +  L_chan = r*tdefl
  +  write(*,*) "Results", tdefl, L_chan
   
     xp_rel = xp - c_miscut
   
  
positive.code: 
    else ! case 3-2: no good for channeling. check if the  can VR
  
      Lrefl = xp_rel*c_rcurv ! Distance of refl. point [m]
      Srefl = sin_mb(xp_rel/two + c_miscut)*Lrefl
  
      if(Lrefl > zero .and. Lrefl < Length) then ! VR point inside
  
negative.code:           x     = x + xp*Srefl
            y     = y + yp*Srefl
  
            Dxp = (((-three*Ang_rms)*xp_rel)/(two*xpcrit) + Ang_avr) + ((three*Ang_rms)*(tdefl))/(two*xpcrit)
            xp  = xp + Dxp
            x   = x + (half*xp)*(s_length-Srefl)
            y   = y + (half*yp)*(s_length-Srefl)
  