anchor.diff:      implicit none
       integer,intent(in) :: d,n(d),m(d),ra(d+1), rmax
       integer,intent(inout) :: ry(d+1)
  -    integer, intent(in), optional :: kickrank, nswp, verb
  +    integer, intent(in), optional :: kickrank, nswp, verb, typ0
       ! verb: 0: off; 1: matlab; 2: console
       integer :: kickrank0, nswp0, verb0
       complex(8), intent(in) :: crA(*), crY0(*)
  
positive.code:     integer,allocatable :: pa(:)
      complex(8), allocatable :: tmp1(:), tmp2(:),tmp3(:,:,:)
      integer :: i,j, k, sz,swp, dir, lwork, mm, nn, rnew, max_matvecs, rmax2 
      double precision :: err, ermax, res, res_old, min_res
      double precision anorm
      integer typ !Type of the scheme, in future it will be KSL vs KSL-symm
      real(8) dznrm2
      complex(8) ZERO, ONE
      parameter( ZERO=(0.0d0,0.0d0), ONE=(1.0d0,0.0d0) )
  
      typ = 2 ! 1 - KSL, 2 - KSL-symm
  
  
      min_res = 1d-1
      rmax2 = rmax 
  
negative.code:     ermax = 0d0
      i = d
      dir = -1
      swp = 0
  
      call init_seed()
      ermax = 0d0
      if ( typ .eq. 1 ) then
          tau0 = tau
      else if ( typ .eq. 2  ) then
  