anchor.diff:                                                       sys%max_number_excitations, weighted_sampling)
   
                   end do
  + 
   
                   ! Sum all quantities being considered across all MPI processes.
                   error = qs%spawn_store%spawn%error .or. qs%psip_list%error .or. rdm_error
  
positive.code:         call check_allocate('tot_nparticles_old', qs%psip_list%nspaces, ierr)
          allocate(real_population(qs%psip_list%nspaces), stat=ierr)
          call check_allocate('real_population', qs%psip_list%nspaces, ierr)
  
          ! It is convenient to setup calculations using a final beta and
          ! target beta instead of calculating the nreports from tau and mc_cycles.
  
negative.code:                                                          qs%ref%f0)
                          end if
  
                          ! HAYLEY
                          if (icycle == 1) then
                              !exlevel_1 =  get_excitation_level(qs%ref%f0,cdet1%f2)
                              !exlevel_2 = get_excitation_level(qs%ref%f0,cdet1%f)
                              !exlevel_1 =  get_excitation_level(cdet1%f,cdet1%f2)
                              !exlevel_2 = exlevel_1
                              !!skip = .false.
                              !!exlevel_ref = get_excitation_level(qs%ref%f0,cdet2%f)
                              !!if (exlevel_ref == 0) then
                              !!    exlevel_1 = get_excitation_level(cdet1%f,cdet1%f2)
                              !!else
                              !!    exlevel_1 = get_excitation_level(cdet1%f,cdet1%f2)
                              !!    skip= .true.
                              !!endif
                              !!exlevel_2 = exlevel_1
                              exlevel_1 = get_excitation_level(qs%ref%f0,cdet2%f)
                              exlevel_2  = get_excitation_level(cdet1%f,cdet1%f2)
                              Nw_current = abs(real(qs%psip_list%pops(1,idet),p))
                              x = floor(log10(abs(Nw_current)))
                              if (x < 0.0_p) then
                                  !call stop_all "not implemented for reals"
                                  write(6,*) "ERROR"
                              end if
                              remainder = log10(Nw_current) - x
                              y = floor(remainder*bins_per_decade) + 1 
                              !y = floor(abs(real(qs%psip_list%pops(1,idet),p))/(10.0_p**(log10(abs(real(qs%psip_list%pops(1,idet),p))))))
                              !z = (9*x)+y !should calculate bin number
                              !write(6,*) x, y, exlevel_1, exlevel_2, exlevel_ref, qs%ref%f0, cdet2%f, cdet1%f
                              !write(6,*) qs%ref%f0, exlevel_1, exlevel_2
                              if (x > xmax) then
                                  write(6,*) "ERROR X too large!"
                              else if (y > bins_per_decade*xmax) then
                                  write(6,*) "ERROR Y too large!" 
                              end if 
                              ! TODO Implement array bound checks on x and y. 
                              !if (.not. skip) counter_var(x,y) = counter_var(x,y) +1.0_p
                              !write(6,*) x, y, Nw_current
                              !if (.not. skip) counter_var(x,y) = counter_var(x,y) +1.0_p
                              !!if (.not. skip) counter_var_ex(x,y,exlevel_1,exlevel_2) = counter_var_ex(x,y,exlevel_1,exlevel_2) +1.0_p
                              !!if (.not. skip) counter_var(x,y) = counter_var(x,y) +1.0_p
                              counter_var_ex(x,y,exlevel_1,exlevel_2) = counter_var_ex(x,y,exlevel_1,exlevel_2) +1.0_p
                              counter_var(x,y) = counter_var(x,y) +1.0_p
                          end if
  
                          !HAYLEY-good code
                          !if (icycle == 1) then
                          !    exlevel = get_excitation_level(cdet1%f,cdet1%f2)
                          !    do x = 0, max_ex_level
                          !        if (exlevel == x) then
                          !            counter_var(x+1) = counter_var(x+1) + abs(real(qs%psip_list%pops(1,idet),p))
                          !        end if
                          !    end do
                          !end if 
                          ! Only attempt spawning if a valid connection exists.
                          attempt_spawning = connection_exists(sys)
  
  