anchor.diff:                                       nspawn_events, unused_int_1, unused_int_2, soft_exit, &
                                        load_bal_in, .false., bloom_stats=bloom_stats)
   
  -                call cpu_time(t2)
  +                call cpu_time(t2) 
  +                ! HAYLEY
  +                !call mpi_gather(counter_var, size(counter_var), mpi_real8, total_count, size(counter_var), & 
  +                !                      mpi_real8, root, MPI_COMM_WORLD, ierr) 
  +                !do x = 1, size(counter_var)
  +                !    tc(x) = 0
  +                !    do y = 1,  nprocs
  +                !        z = x + size(counter_var)*(y-1)
  +                !        tc(x) = tc(x) + total_count(z)
  +                !    end do
  +                !end do
  +                call mpi_reduce(counter_var,tc, size(counter_var), mpi_real8, mpi_sum, root, MPI_COMM_WORLD, ierr)
  +                call mpi_reduce(counter_var_ex,tc_ex, size(counter_var_ex), mpi_real8, mpi_sum, root, MPI_COMM_WORLD, ierr)
  +                !call mpi_gather(counter_var_ex, size(counter_var_ex), mpi_real8, total_count_ex, size(counter_var_ex), & 
  +                !                       mpi_real8, root, MPI_COMM_WORLD, ierr) 
  +                !do x = 1, 63
  +                !    tc(x) = 0
  +                !    do y = 0, 28
  +                !        z = x + (63*10)*y
  +                !        tc_ex(x) = tc_ex(x) + total_count_ex(z)
  +                !    end do
  +                !end do
  +
  +                !write(6,*) 'Counter var 6,5:', counter_var(6,5)
  +                !write(6,*) 'Total count 6,5:', tc(6,5)
  +                !write(6,*) 'Counter var 1,1:', counter_var(1,1)
  +                !write(6,*) 'Total count 1,1:', tc(1,1)
  +    
  +                iiunit = 6
                   if (parent) then
                       if (bloom_stats%nblooms_curr > 0) call bloom_stats_warning(bloom_stats)
                       call write_dmqmc_report(sys, qmc_in, qs, ireport, tot_nparticles_old, t2-t1, .false., &
                                               dmqmc_in, dmqmc_estimates, sys%read_in%comp)
  +                    inquire(file=ffname, exist=exist)
  +                    if (.not. exist) then
  +                        write (ffname, '(A7,I0)') 'DETPOPS', iproc
  +                        open(newunit=iiunit, file=ffname, status='unknown')
  +                        do x =0, size(tc,1)-1
  +                            !write (iiunit, '(A)')
  +                            do y =1, size(tc,2)
  +                                !write (iiunit, '(2X,A10,I3)', advance='no'), 'Hist. Grp.', 
  +                                write (iiunit, '(es18.10)', advance='no'), 10.0_p**(x+1.0_p/bins_per_decade*(y-1.0_p))
  +                            end do
  +                        end do
  +                        write (iiunit, '(A)') 
  +                        close(iiunit, status='keep')
  +                        !open(newunit=iiunit, file=ffname, status="old", position='append',action='write')
  +                        !do x = 1, size(tc)
  +                        !    write (iiunit,'(es15.4)',advance='no') tc(x)
  +                        !end do
  +                    end if
  +                    open(newunit=iiunit, file=ffname, status="old", position='append',action='write')
  +                    do x = 0, size(tc,1)-1
  +                        !write (iiunit, '(A)') 
  +                        do y =1, size(tc,2)
  +                            write (iiunit,'(es18.10)',advance='no') tc(x,y)
  +                        end do
  +                    end do
  +                    close(iiunit, status='keep')
  +                !write(6,*) size(tc,1)
  +                !write(6,*) size(tc,2)
                   end if
  +
  +                counter_var = 0.0_p
  +                tc = 0.0_p
  +                
  +                ! Only want to print the full excitation level spectrums at the
  +                ! end of the calculation. 
  +                if (parent .and. ireport == nreport) then
  +                    !inquire(file=fffname, exist=exist)
  +                    !if (exist) then
  +                    !    open(newunit=iiunit, file=fffname, status="old", position='append',action='write')
  +                    !    do x = 0.0_p, log10(qs%target_particles)
  +                    !        do y = 1.0_p, 9.0_p
  +                    !            write (iiunit, '(A)')
  +                    !            thresh = (10.0_p**x)*y
  +                    !            thresh2 = (10.0_p**x)*(y+1)
  +                    !            write (iiunit, '(es15.4,es15.4)',advance='no') thresh, thresh2
  +                    !            do ex =0, max_ex_level
  +                    !                z = ((9*(log10(qs%target_particles)+1)) * ex)+((9*x)+y)
  +                    !                write (iiunit,'(es15.4)',advance='no') tc_ex(z)
  +                    !            end do
  +                    !         end do
  +                    !    end do
  +                    !else
  +                    write (fffname, '(A11)') 'EXLEVELPOPS'
  +                    open(newunit=iiunit, file=fffname, status='unknown')
  +                    do x =0, max_ex_level
  +                        do x2 = 0, max_ex_level
  +                        !if (x == 0) then
  +                            !write (iiunit, '(6X,A13,6X,A13)', advance='no'), 'Threshold Min', 'Threshold Max'
  +                            !write (iiunit, '(6X,A13,I6)', advance='no'), 'Ex. Level', x
  +                        !else
  +                             write (iiunit, '(6X,A6,I3,I3)', advance='no'), 'Ex.Lvl', int(x), int(x2)
  +                        end do
  +                        !end if
  +                     end do
  +                     write (iiunit, '(A)') 
  +                     do w = 0, xmax
  +                        do v = 1, bins_per_decade
  +                            write (iiunit, '(A)')
  +                            do ex_1 =0, max_ex_level
  +                                do ex_2=0, max_ex_level
  +                                !z = (9*w)+v
  +                                    write (iiunit,'(es18.10)',advance='no') tc_ex(w,v,ex_1,ex_2)
  +                                end do
  +                            end do
  +                         end do
  +                    end do
  +                    !end if
  +                    close(iiunit, status='keep')
  +                    write (ggname, '(A7,I0)') 'INDICES', iproc
  +                    open(newunit=iiunit, file=ggname, status='unknown')
  +                    do w = 0, xmax
  +                        do v = 1, bins_per_decade
  +                            write (iiunit, '(A)')
  +                            do ex_1=0, max_ex_level
  +                                do ex_2 = 0, max_ex_level
  +                                    write (iiunit,'(I3,I3,I3,I3)',advance='no') w, v, ex_1,ex_2
  +                                end do
  +                             end do
  +                         end do
  +                    end do
  +                    write (gggname, '(A14,I0)') 'INDICESDETPOPS', iproc
  +                    open(newunit=iiunit, file=gggname, status='unknown')
  +                    do x = 0,size(tc,1)-1
  +                        do y  = 1,size(tc,2)
  +                            write (iiunit,'(I3,I3)',advance='no') x, y
  +                            write (iiunit, '(es18.10)', advance='no'), 10.0_p**(x+1.0_p/bins_per_decade*(y-1.0_p))
  +                        end do
  +                    end do
  +                    close(iiunit, status='keep')
  +                end if
  + 
  +                counter_var_ex = 0.0_p
  +                tc_ex = 0.0_p
   
                   ! Update the time for the start of the next iteration.
                   t1 = t2
  -
                   if (soft_exit) exit outer_loop
   
               end do
  
positive.code: 
              ! DMQMC quasi-newton not functional, so we artificially set this value to 0 which should not affect non-QN calcs.
              qs%estimators%proj_energy_old = 0_p
  
              do ireport = 1, nreport
  
                  call init_dmqmc_report_loop(calc_ref_proj_energy, dmqmc_in%calc_excit_dist, dmqmc_in%calc_mom_dist, &
  
negative.code:                                                      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
  