subroutine normalize_gf_overlap(overlapList, avReal, avImag)
implicit none
complex(dp), intent(out) :: overlapList(normsize, gf_count)
real(dp), intent(out) :: avReal(gf_count), avImag(gf_count)
integer :: i, j
complex(dp), allocatable :: overlap_buf(:)
allocate(overlap_buf(gf_count))
call update_gf_overlap()
do j = 1, gf_count
do i = 1, normsize
overlapList(i, j) = gf_overlap(i, j) / dyn_norm_red(i, j) * &
exp(shift_damping(((i - 1) / inum_runs + 1)))
end do
!normalize the greens function
overlap_buf(j) = sum(gf_overlap(:, j)) / sum(dyn_norm_red(:, j)) * &
sum(exp(shift_damping)) / inum_runs
avReal(j) = real(overlap_buf(j))
avImag(j) = aimag(overlap_buf(j))
end do
deallocate(overlap_buf)
end subroutine normalize_gf_overlap