Compatible discretization of hamiltonian systems and symplectic groupoids