anchor.diff:  
     subroutine initialize_from_multiplicities(nk1, zk1, nc)
       ! set nk, zk, n_data, alphabet_size
  -    real(float64), intent(in) :: nk1(:)
  -    real(float64), intent(in) :: zk1(:)
  +    integer, intent(in) :: nk1(:)
  +    integer, intent(in) :: zk1(:)
       real(float64), intent(in) :: nc
       integer :: idx=-1, err, j, nm
   
       alphabet_size = nc
   
  -    call counts_reset()
  -    allocate(nk(size(nk1)), stat=err)
  -    allocate(zk(size(zk1)), stat=err)
  -    nk = nk1
  -    zk = zk1
  -
  -    n_data = sum(zk * nk)
  -    n_bins = sum(zk)
  -    k1 = sum(zk, nk>0)
  +    call counts_fit(nk1, zk1)
   
       call add_empty_bins(alphabet_size)
   
  
positive.code:     end if
    end subroutine counts_reset
  
    subroutine counts_fit(ar)
      implicit none
      integer, intent(in) :: ar(:)
      integer :: i, j, u
      integer :: x, err
      integer :: xmax
  
negative.code: 
      call counts_reset()
  
      if (present(br)) then  ! multiplicities
         allocate(nk(size(ar)), stat=err)
         allocate(zk(size(br)), stat=err)
         nk = ar
         zk = br
      else
         xmax = maxval(ar)
         allocate(wrk(0:xmax), stat=err)
         wrk = 0
         u = 0
         do i = 1,ubound(ar, 1)
            x = ar(i)
            if (wrk(x) == 0) then
               u = u + 1
            end if
            wrk(x) = wrk(x) + 1
         end do
  
         allocate(nk(u), zk(u), stat=err)
  
         u = 0
         do i = 0, xmax
            x = wrk(i)
            if (x > 0) then
               u = u + 1
               nk(u) = i
               zk(u) = x
            end if
         end do
  
      end if
  
      n_data = sum(zk * nk)
      n_bins = sum(zk)
  