The compressible adjoint equations in geodynamics: derivation and numerical assessment