  Numerical models of weather and climate critically depend on long-term
stability of integrators for systems of hyperbolic conservation laws. While
such stability is often obtained from (physical or numerical) dissipation
terms, physical fidelity of such simulations also depends on properly
preserving conserved quantities, such as energy, of the system. To address this
apparent paradox, we develop a variational integrator for the shallow water
equations that conserves energy, but dissipates potential enstrophy. Our
approach follows the continuous selective decay framework [F. Gay-Balmaz and D.
Holm. Selective decay by Casimir dissipation in inviscid fluids. Nonlinearity,
26(2):495, 2013], which enables dissipating an otherwise conserved quantity
while conserving the total energy. We use this in combination with the
variational discretization method [D. Pavlov, P. Mullen, Y. Tong, E. Kanso, J.
Marsden and M. Desbrun. Structure-preserving discretization of incompressible
fluids. Physica D: Nonlinear Phenomena, 240(6):443-458, 2011] to obtain a
discrete selective decay framework. This is applied to the shallow water
equations, both in the plane and on the sphere, to dissipate the potential
enstrophy. The resulting scheme significantly improves the quality of the
approximate solutions, enabling long-term integrations to be carried out.
