, which greatly improved the readability and presentation of this paper; and to Colin Cotter, Tom Melvin and Golo Wimmer for many illuminating discussions about the application of Hamiltonian and compatible Galerkin methods for geophysical fluids. We are also thankful to David Ham, Lawrence Mitchell and Miklos Homolya for assistance with development of Themis, without which this work would have been much harder, We are grateful to Colin Cotter and Almut Gassmann for their detailed and thorough reviews

P. Ripa, Conservation laws for primitive equations models with inhomogeneous layers, Geophysical & Astrophysical Fluid Dynamics, vol.70, issue.1-4, pp.85-111, 1993.

T. Dubos, S. Dubey, M. Tort, R. Mittal, Y. Meurdesoif et al., Dynamico-1.0, an icosahedral hydrostatic dynamical core designed for consistency and versatility, Geoscientific Model Development, vol.8, issue.10, 2015.
URL : https://hal.archives-ouvertes.fr/hal-01266387

T. Dubos and M. Tort, Equations of atmospheric motion in non-eulerian vertical coordinates: Vector-invariant form and quasi-hamiltonian formulation, Monthly Weather Review, vol.142, issue.10, pp.3860-3880, 2014.

P. J. Dellar, Common hamiltonian structure of the shallow water equations with horizontal temperature gradients and magnetic fields, Physics of Fluids, vol.15, issue.2, pp.292-297, 2003.

E. S. Warneford and P. J. Dellar, The quasi-geostrophic theory of the thermal shallow water equations, Journal of Fluid Mechanics, vol.723, pp.374-403, 2013.

E. Gouzien, N. Lahaye, V. Zeitlin, and T. Dubos, Thermal instability in rotating shallow water with horizontal temperature/density gradients, Physics of Fluids, vol.29, issue.10, p.101702, 2017.

E. S. Warneford and P. J. Dellar, Thermal shallow water models of geostrophic turbulence in jovian atmospheres, Physics of Fluids, vol.26, issue.1, p.16603, 2014.

E. S. Warneford and P. J. Dellar, Super-and sub-rotating equatorial jets in shallow water models of jovian atmospheres: Newtonian cooling versus rayleigh friction, Journal of Fluid Mechanics, vol.822, pp.484-511, 2017.

C. Cotter and J. Shipton, Mixed finite elements for numerical weather prediction, Journal of Computational Physics, vol.231, issue.21, pp.7076-7091, 2012.

A. T. Mcrae and C. J. Cotter, Energy-and enstrophy-conserving schemes for the shallow-water equations, based on mimetic finite elements, Quarterly Journal of the Royal Meteorological Society, vol.140, issue.684, 2014.

A. Natale, J. Shipton, and C. J. Cotter, Compatible finite element spaces for geophysical fluid dynamics, Dynamics and Statistics of the Climate System, vol.1, issue.1, p.5, 2016.

A. Arakawa and V. R. Lamb, A potential enstrophy and energy conserving scheme for the shallow water equations, Monthly Weather Review, vol.109, issue.1, pp.18-36, 1981.

A. L. Stewart and P. J. Dellar, An energy and potential enstrophy conserving numerical scheme for the multi-layer shallow water equations with complete coriolis force, Journal of Computational Physics, vol.313, pp.99-120, 2016.

C. Eldred and D. Randall, Total energy and potential enstrophy conserving schemes for the shallow water equations using hamiltonian methods-part 1: Derivation and properties, Geoscientific Model Development, vol.10, issue.2, pp.791-810, 2017.

T. Ringler, J. Thuburn, J. Klemp, and W. Skamarock, A unified approach to energy conservation and potential vorticity dynamics for arbitrarily-structured c-grids, Journal of Computational Physics, vol.229, issue.9, pp.3065-3090, 2010.

R. Sadourny, The dynamics of finite-difference models of the shallow-water equations, Journal of the Atmospheric Sciences, vol.32, issue.4, pp.680-689, 1975.

J. Thuburn and C. J. Cotter, A framework for mimetic discretization of the rotating shallow-water equations on arbitrary polygonal grids, SIAM Journal on Scientific Computing, vol.34, issue.3, pp.203-225, 2012.

M. A. Taylor and A. Fournier, A compatible and conservative spectral element method on unstructured grids, Journal of Computational Physics, vol.229, issue.17, pp.5879-5895, 2010.

D. Lee, A. Palha, and M. Gerritsma, Discrete conservation properties for shallow water flows using mixed mimetic spectral elements, Journal of Computational Physics, vol.357, pp.282-304, 2018.

J. Shipton, T. Gibson, and C. Cotter, Higher-order compatible finite element schemes for the nonlinear rotating shallow water equations on the sphere, Journal of Computational Physics, vol.375, pp.1121-1137, 2018.

J. Thuburn and C. J. Cotter, A primal-dual mimetic finite element scheme for the rotating shallow water equations on polygonal spherical meshes, Journal of Computational Physics, vol.290, pp.274-297, 2015.

H. Yamazaki, J. Shipton, M. J. Cullen, L. Mitchell, and C. J. Cotter, Vertical slice modelling of nonlinear eady waves using a compatible finite element method, Journal of Computational Physics, vol.343, pp.130-149, 2017.

P. S. Peixoto, Accuracy analysis of mimetic finite volume operators on geodesic grids and a consistent alternative, Journal of Computational Physics, vol.310, pp.127-160, 2016.

C. Eldred and D. Y. Roux, Dispersion analysis of compatible galerkin schemes for the 1d shallow water model, Journal of Computational Physics, vol.371, pp.779-800, 2018.
URL : https://hal.archives-ouvertes.fr/hal-01669048

A. Gassmann, Inspection of hexagonal and triangular c-grid discretizations of the shallow water equations, Journal of Computational Physics, vol.230, issue.7, pp.2706-2721, 2011.

T. Melvin, Dispersion analysis of the pn-pn-1dg mixed finite element pair for atmospheric modelling, Journal of Computational Physics, vol.355, pp.342-365, 2018.

T. Melvin, A. Staniforth, and C. Cotter, A two-dimensional mixed finite-element pair on rectangles, Quarterly Journal of the Royal Meteorological Society, vol.140, issue.680, pp.930-942, 2014.

T. Melvin and J. Thuburn, Wave dispersion properties of compound finite elements, Journal of Computational Physics, vol.338, pp.68-90, 2017.

V. Rostand, D. Y. Roux, and G. Carey, Kernel analysis of the discretized finite difference and finite element shallow-water models, SIAM Journal on Scientific Computing, vol.31, issue.1, pp.531-556, 2008.

D. Y. Roux, Spurious inertial oscillations in shallow-water models, Journal of Computational Physics, vol.231, issue.24, pp.7959-7987, 2012.
URL : https://hal.archives-ouvertes.fr/hal-00864893

A. Staniforth, T. Melvin, and C. Cotter, Analysis of a mixed finite-element pair proposed for an atmospheric dynamical core, Quarterly Journal of the Royal Meteorological Society, vol.139, issue.674, pp.1239-1254, 2013.

J. Thuburn, Numerical wave propagation on the hexagonal c-grid, Journal of Computational Physics, vol.227, issue.11, pp.5836-5858, 2008.

S. Ni?kovi?, M. B. Gavrilov, and I. A. To?i?, Geostrophic adjustment on hexagonal grids, Monthly Weather Review, vol.130, issue.3, pp.668-683, 2002.

J. Thuburn, T. Ringler, W. Skamarock, and J. Klemp, Numerical representation of geostrophic modes on arbitrarily structured c-grids, Journal of Computational Physics, vol.228, issue.22, pp.8321-8335, 2009.

J. Thuburn, C. J. Cotter, and T. Dubos, A mimetic, semi-implicit, forward-in-time, finite volume shallow water model: comparison of hexagonal-icosahedral and cubed-sphere grids, Geoscientific Model Development, vol.7, issue.3, pp.909-929, 2014.
URL : https://hal.archives-ouvertes.fr/hal-01081467

H. Weller, Non-orthogonal version of the arbitrary polygonal c-grid and a new diamond grid, Geoscientific Model Development, vol.7, issue.3, pp.779-797, 2014.

M. J. Bell, P. S. Peixoto, and J. Thuburn, Numerical instabilities of vector-invariant momentum equations on rectangular c-grids, Quarterly Journal of the Royal Meteorological Society, vol.143, issue.702, pp.563-581, 2017.

A. Hollingsworth, P. Kållberg, V. Renner, and D. M. Burridge, An internal symmetric computational instability, Quarterly Journal of the Royal Meteorological Society, vol.109, issue.460, pp.417-428, 1983.
DOI : 10.1002/qj.49710946012

L. Lazi?, Z. Janji?, and F. Mesinger, non-cancellation" instability in horizontal advection schemes for momentum equations, Meteorology and Atmospheric Physics, vol.35, issue.1, pp.49-52, 1986.

P. Peixoto, J. Thuburn, and M. Bell, Numerical instabilities of spherical shallow water models considering small equivalent depths, Quarterly Journal of the Royal Meteorological SocietyQJ

A. Gassmann, Discretization of generalized coriolis and friction terms on the deformed hexagonal c-grid, Quarterly Journal of the Royal Meteorological Society, issue.0, p.0

W. Bauer and C. Cotter, Energy-enstrophy conserving compatible finite element schemes for the rotating shallow water equations with slip boundary conditions, Journal of Computational Physics, 2018.

R. Salmon, Poisson-bracket approach to the construction of energyand potential-enstrophy-conserving algorithms for the shallow-water equations, Journal of the Atmospheric Sciences, vol.61, issue.16, pp.2016-2036, 2004.

M. Sommer and P. Névir, A conservative scheme for the shallow-water system on a staggered geodesic grid based on a nambu representation, Quarterly Journal of the Royal Meteorological Society, vol.135, issue.639, pp.485-494, 2009.

A. Gassmann, A global hexagonal c-grid non-hydrostatic dynamical core (icon-iap) designed for energetic consistency, Quarterly Journal of the Royal Meteorological Society, vol.139, issue.670, pp.152-175, 2013.

A. Gassmann and H. Herzog, Towards a consistent numerical compressible nonhydrostatic model using generalized hamiltonian tools, Quarterly Journal of the Royal Meteorological Society, vol.134, issue.635, pp.1597-1613, 2008.

M. Tort, T. Dubos, and T. Melvin, Energy-conserving finite-difference schemes for quasihydrostatic equations, Quarterly Journal of the Royal Meteorological Society, vol.141, issue.693, pp.3056-3075, 2015.

M. D. Toy and R. D. Nair, A potential enstrophy and energy conserving scheme for the shallow-water equations extended to generalized curvilinear coordinates, Monthly Weather Review, vol.145, issue.3, pp.751-772, 2017.

E. Kritsikis and T. Dubos, Higher-order finite elements for the shallow-water equations on the cubed sphere, 2014.

T. G. Shepherd, A unified theory of available potential energy, vol.31, pp.1-26, 1993.

P. Ripa, Linear waves in a one-layer ocean model with thermodynamics, Journal of Geophysical Research: Oceans, vol.101, issue.C1, pp.1233-1245, 1996.

D. N. Arnold, R. S. Falk, and R. Winther, Finite element exterior calculus, homological techniques, and applications, Acta Numerica, vol.15, pp.1-155, 2006.
DOI : 10.1017/s0962492906210018

R. Hiemstra, D. Toshniwal, R. Huijsmans, and M. Gerritsma, High order geometric methods with exact conservation properties, physics-compatible numerical methods, vol.257, pp.1444-1471, 2014.
DOI : 10.1016/j.jcp.2013.09.027

A. Staniforth and J. Thuburn, Horizontal grids for global weather and climate prediction models: a review, Quarterly Journal of the Royal Meteorological Society, vol.138, issue.662, pp.1-26, 2012.

D. Arnold, R. Falk, and R. Winther, Finite element exterior calculus: from hodge theory to numerical stability, Bulletin of the American mathematical society, vol.47, issue.2, pp.281-354, 2010.

S. Danilov, On utility of triangular c-grid type discretization for numerical modeling of large-scale ocean flows, Ocean Dynamics, vol.60, issue.6, pp.1361-1369, 2010.

A. Mcrae, G. Bercea, L. Mitchell, D. Ham, and C. Cotter, Automated generation and symbolic manipulation of tensor product finite elements, SIAM Journal on Scientific Computing, vol.38, issue.5, pp.25-47, 2016.

A. Buffa, J. Rivas, G. Sangalli, and R. Vazquez, Isogeometric discrete differential forms in three dimensions, SIAM Journal on Numerical Analysis, vol.49, issue.2, pp.818-844, 2011.

A. Buffa, G. Sangalli, and R. Vazquez, Isogeometric methods for computational electromagnetics: B-spline and t-spline discretizations, physics-compatible numerical methods, vol.257, pp.1291-1320, 2014.
DOI : 10.1016/j.jcp.2013.08.015

URL : http://arxiv.org/pdf/1209.2048

J. Banks and T. Hagstrom, On galerkin difference methods, Journal of Computational Physics, vol.313, pp.310-327, 2016.
DOI : 10.1016/j.jcp.2016.02.042

URL : https://manuscript.elsevier.com/S0021999116001121/pdf/S0021999116001121.pdf

A. Sarmiento, A. Cortes, D. Garcia, L. Dalcin, N. Collier et al., Petigamf: A multi-field high-performance toolbox for structure-preserving b-splines spaces, Journal of Computational Science, vol.18, pp.117-131, 2017.

W. Bauer, A new hierarchically-structured n-dimensional covariant form of rotating equations of geophysical fluid dynamics, vol.7, pp.31-101, 2016.

J. B. Perot and C. J. Zusi, Differential forms for scientists and engineers, physics-compatible numerical methods, vol.257, pp.1373-1393, 2014.

E. Tonti, Why starting from differential equations for computational physics?, Journal of Computational Physics, vol.257, pp.1260-1290, 2014.

M. E. Rognes, D. A. Ham, C. J. Cotter, and A. T. Mcrae, Automating the solution of pdes on the sphere and other manifolds in fenics 1.2, Geoscientific Model Development, vol.6, issue.6, pp.2099-2119, 2013.

H. Heumann, R. Hiptmair, and C. Pagliantini, Stabilized galerkin for transient advection of differential forms, Discrete and Continuous Dynamical Systems, vol.9, p.185, 2016.
URL : https://hal.archives-ouvertes.fr/hal-01119481

A. Natale and C. J. Cotter, Scale-selective dissipation in energy-conserving finite-element schemes for two-dimensional turbulence, Quarterly Journal of the Royal Meteorological Society, vol.143, issue.705, pp.1734-1745, 2017.
DOI : 10.1002/qj.3063

URL : http://arxiv.org/pdf/1611.02623

A. Natale and C. J. Cotter, A variational H(div) finite-element discretization approach for perfect incompressible fluids, IMA Journal of Numerical Analysis, 2017.
DOI : 10.1093/imanum/drx033

URL : http://arxiv.org/pdf/1606.06199

R. I. Mclachlan, Spatial discretization of partial differential equations with integrals, IMA Journal of Numerical Analysis, vol.23, issue.4, pp.645-664, 2003.

D. Cohen and E. Hairer, Linear energy-preserving integrators for poisson systems, BIT Numerical Mathematics, vol.51, issue.1, pp.91-101, 2011.
DOI : 10.1007/s10543-011-0310-z

URL : https://archive-ouverte.unige.ch/unige:14887/ATTACHMENT01

T. Benacchio and N. Wood, Semi-implicit semi-lagrangian modelling of the atmosphere: A met office perspective, Communications in Applied and Industrial Mathematics, vol.7, pp.4-25, 2016.
DOI : 10.1515/caim-2016-0020

URL : https://content.sciendo.com/downloadpdf/journals/caim/7/3/article-p4.pdf

N. Wood, A. Staniforth, A. White, T. Allen, M. Diamantakis et al., An inherently mass-conserving semiimplicit semi-lagrangian discretization of the deep-atmosphere global non-hydrostatic equations, Quarterly Journal of the Royal Meteorological Society, vol.140, issue.682, pp.1505-1520, 2014.
DOI : 10.1002/qj.2235

C. Eldred, Themis web page, 2018.

F. Rathgeber, D. A. Ham, L. Mitchell, M. Lange, F. Luporini et al., Firedrake: Automating the finite element method by composing abstractions, ACM Trans. Math. Softw, vol.43, issue.3, p.27, 2016.

M. S. Alnaes, A. Logg, K. B. Olgaard, M. E. Rognes, and G. N. Wells, Unified form language: A domain-specific language for weak formulations of partial differential equations, ACM Trans. Math. Softw, vol.40, issue.2, p.37, 2014.

M. Homolya, R. C. Kirby, and D. A. Ham, Exposing and exploiting structure: optimal code generation for high-order finite element methods

M. Homolya, L. Mitchell, F. Luporini, and D. A. Ham, TSFC: a structure-preserving form compiler
DOI : 10.1137/17m1130642

URL : http://arxiv.org/pdf/1705.03667

P. Finat-web, , 2018.

F. Luporini, D. A. Ham, and P. H. Kelly, An algorithm for the optimization of finite element integration loops, ACM Trans. Math. Softw, vol.44, issue.1, 2017.

F. Luporini, A. L. Varbanescu, F. Rathgeber, G. Bercea, J. Ramanujam et al., Cross-loop optimization of arithmetic intensity for finite element local assembly, ACM Trans. Archit. Code Optim, vol.11, issue.4, p.25, 2015.

R. C. Kirby, Algorithm 839: Fiat, a new paradigm for computing finite element basis functions, ACM Trans. Math. Softw, vol.30, issue.4, pp.502-516, 2004.

S. Balay, S. Abhyankar, M. F. Adams, J. Brown, P. Brune et al., , 2018.

D. L. Williamson, J. B. Drake, J. J. Hack, R. Jakob, and P. N. Swarztrauber, A standard test set for numerical approximations to the shallow water equations in spherical geometry, Journal of Computational Physics, vol.102, issue.1, pp.211-224, 1992.

M. Giorgetta, T. Hundertmark, P. Korn, S. Reich, and M. Restelli, Conservative Space and Time Regularizations for the ICON Model

T. Dubos, A variational formulation of geophysical fluid motion in non-eulerian coordinates, Quarterly Journal of the Royal Meteorological Society, vol.143, issue.702, pp.542-551, 2017.