Skip to content
Snippets Groups Projects
apdx_invariants.tex 71.4 KiB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
\documentclass[../main/NEMO_manual]{subfiles}

\begin{document}

\chapter{Discrete Invariants of the Equations}
\label{apdx:INVARIANTS}

\chaptertoc

\paragraph{Changes record} ~\\

{\footnotesize
  \begin{tabularx}{\textwidth}{l||X|X}
    Release & Author(s) & Modifications \\
    \hline
    {\em   4.0} & {\em ...} & {\em ...} \\
    {\em   3.6} & {\em ...} & {\em ...} \\
    {\em   3.4} & {\em ...} & {\em ...} \\
    {\em <=3.4} & {\em ...} & {\em ...}
  \end{tabularx}
}

\clearpage

%%%  Appendix put in cmtgm as it has not been updated for \zstar and s coordinate
%I'm writting this appendix. It will be available in a forthcoming release of the documentation

%\cmtgm{

%% =================================================================================================
\section{Introduction / Notations}
\label{sec:INVARIANTS_0}

Notation used in this appendix in the demonstations:

fluxes at the faces of a $T$-box:
\[
  U = e_{2u}\,e_{3u}\; u  \qquad  V = e_{1v}\,e_{3v}\; v  \qquad W = e_{1w}\,e_{2w}\; \omega
\]

volume of cells at $u$-, $v$-, and $T$-points:
\[
  b_u = e_{1u}\,e_{2u}\,e_{3u}  \qquad  b_v = e_{1v}\,e_{2v}\,e_{3v}  \qquad b_t = e_{1t}\,e_{2t}\,e_{3t}
\]

partial derivative notation: $\partial_\bullet = \frac{\partial}{\partial \bullet}$

$dv=e_1\,e_2\,e_3 \,di\,dj\,dk$  is the volume element, with only $e_3$ that depends on time.
$D$ and $S$ are the ocean domain volume and surface, respectively.
No wetting/drying is allow (\ie\ $\frac{\partial S}{\partial t} = 0$).
Let $k_s$ and $k_b$ be the ocean surface and bottom, resp.
(\ie\ $s(k_s) = \eta$ and $s(k_b)=-H$, where $H$ is the bottom depth).
\begin{flalign*}
  z(k) = \eta - \int\limits_{\tilde{k}=k}^{\tilde{k}=k_s}  e_3(\tilde{k}) \;d\tilde{k}
  = \eta - \int\limits_k^{k_s}  e_3 \;d\tilde{k}
\end{flalign*}

Continuity equation with the above notation:
\[
  \frac{1}{e_{3t}} \partial_t (e_{3t})+ \frac{1}{b_t}  \biggl\{  \delta_i [U] + \delta_j [V] + \delta_k [W] \biggr\} = 0
\]

A quantity, $Q$ is conserved when its domain averaged time change is zero, that is when:
\[
  \partial_t \left( \int_D{ Q\;dv } \right) =0
\]
Noting that the coordinate system used ....  blah blah
\[
  \partial_t \left( \int_D {Q\;dv} \right) =  \int_D { \partial_t \left( e_3 \, Q \right) e_1e_2\;di\,dj\,dk }
  =  \int_D { \frac{1}{e_3} \partial_t \left( e_3 \, Q \right) dv } =0
\]
equation of evolution of $Q$ written as
the time evolution of the vertical content of $Q$ like for tracers, or momentum in flux form,
the quadratic quantity $\frac{1}{2}Q^2$ is conserved when:
\begin{flalign*}
  \partial_t \left(   \int_D{ \frac{1}{2} \,Q^2\;dv }   \right)
  =&  \int_D{ \frac{1}{2} \partial_t \left( \frac{1}{e_3}\left( e_3 \, Q \right)^2 \right) e_1e_2\;di\,dj\,dk } \\
  =&  \int_D {         Q   \;\partial_t\left( e_3 \, Q \right) e_1e_2\;di\,dj\,dk }
  -  \int_D { \frac{1}{2} Q^2 \,\partial_t  (e_3) \;e_1e_2\;di\,dj\,dk } \\
\end{flalign*}
that is in a more compact form :
\begin{flalign}
  \label{eq:INVARIANTS_Q2_flux}
  \partial_t \left( \int_D {\frac{1}{2} Q^2\;dv} \right)
  =&                   \int_D { \frac{Q}{e_3}  \partial_t \left( e_3 \, Q \right) dv }
  -   \frac{1}{2} \int_D {  \frac{Q^2}{e_3} \partial_t (e_3) \;dv }
\end{flalign}
equation of evolution of $Q$ written as the time evolution of $Q$ like for momentum in vector invariant form,
the quadratic quantity $\frac{1}{2}Q^2$ is conserved when:
\begin{flalign*}
  \partial_t \left( \int_D {\frac{1}{2} Q^2\;dv} \right)
  =&  \int_D { \frac{1}{2} \partial_t \left( e_3 \, Q^2 \right) \;e_1e_2\;di\,dj\,dk } \\
  =& \int_D {         Q      \partial_t Q  \;e_1e_2e_3\;di\,dj\,dk }
  +  \int_D { \frac{1}{2} Q^2 \, \partial_t e_3  \;e_1e_2\;di\,dj\,dk } \\
\end{flalign*}
that is in a more compact form:
\begin{flalign}
  \label{eq:INVARIANTS_Q2_vect}
  \partial_t \left( \int_D {\frac{1}{2} Q^2\;dv} \right)
  =& \int_D {         Q   \,\partial_t Q  \;dv }
  +   \frac{1}{2} \int_D { \frac{1}{e_3} Q^2 \partial_t e_3 \;dv }
\end{flalign}

%% =================================================================================================
\section{Continuous conservation}
\label{sec:INVARIANTS_1}

The discretization of pimitive equation in $s$-coordinate (\ie\ time and space varying vertical coordinate)
must be chosen so that the discrete equation of the model satisfy integral constrains on energy and enstrophy.

Let us first establish those constraint in the continuous world.
The total energy (\ie\ kinetic plus potential energies) is conserved:
\begin{flalign}
  \label{eq:INVARIANTS_Tot_Energy}
  \partial_t \left( \int_D \left( \frac{1}{2} {\textbf{U}_h}^2 +  \rho \, g \, z \right) \;dv \right)  = & 0
\end{flalign}
under the following assumptions: no dissipation, no forcing (wind, buoyancy flux, atmospheric pressure variations),
mass conservation, and closed domain.

This equation can be transformed to obtain several sub-equalities.
The transformation for the advection term depends on whether the vector invariant form or
the flux form is used for the momentum equation.
Using \autoref{eq:INVARIANTS_Q2_vect} and introducing \autoref{eq:SCOORD_dyn_vect} in
\autoref{eq:INVARIANTS_Tot_Energy} for the former form and
using \autoref{eq:INVARIANTS_Q2_flux} and introducing \autoref{eq:SCOORD_dyn_flux} in
\autoref{eq:INVARIANTS_Tot_Energy} for the latter form leads to:

% \label{eq:INVARIANTS_E_tot}
advection term (vector invariant form):
\[
  % \label{eq:INVARIANTS_E_tot_vect_vor_1}
  \int\limits_D  \zeta \; \left( \textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv   = 0   \\
\]
\[
  % \label{eq:INVARIANTS_E_tot_vect_adv_1}
  \int\limits_D  \textbf{U}_h \cdot \nabla_h \left( \frac{{\textbf{U}_h}^2}{2} \right)     dv
  + \int\limits_D  \textbf{U}_h \cdot \nabla_z \textbf{U}_h  \;dv
  -  \int\limits_D { \frac{{\textbf{U}_h}^2}{2} \frac{1}{e_3} \partial_t e_3 \;dv }   = 0
\]
advection term (flux form):
\[
  % \label{eq:INVARIANTS_E_tot_flux_metric}
  \int\limits_D  \frac{1} {e_1 e_2 } \left( v \,\partial_i e_2 - u \,\partial_j e_1  \right)\;
  \left(  \textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv   = 0
\]
\[
  % \label{eq:INVARIANTS_E_tot_flux_adv}
  \int\limits_D \textbf{U}_h \cdot     \left(                 {{
        \begin{array} {*{20}c}
          \nabla \cdot \left( \textbf{U}\,u \right) \hfill \\
          \nabla \cdot \left( \textbf{U}\,v \right) \hfill
        \end{array}}
    }           \right)   \;dv
  +   \frac{1}{2} \int\limits_D {  {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t e_3 \;dv } =\;0
\]
coriolis term
\[
  % \label{eq:INVARIANTS_E_tot_cor}
  \int\limits_D  f   \; \left( \textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv   = 0
\]
pressure gradient:
\[
  % \label{eq:INVARIANTS_E_tot_pg_1}
  - \int\limits_D  \left. \nabla p \right|_z \cdot \textbf{U}_h \;dv
  = - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
  + \int\limits_D g\, \rho \; \partial_t z  \;dv
\]

where $\nabla_h = \left. \nabla \right|_k$ is the gradient along the $s$-surfaces.

blah blah....

The prognostic ocean dynamics equation can be summarized as follows:
\[
  \text{NXT} = \dbinom	{\text{VOR} + \text{KEG} + \text {ZAD} }
  {\text{COR} + \text{ADV}                       }
  + \text{HPG} + \text{SPG} + \text{LDF} + \text{ZDF}
\]

Vector invariant form:
% \label{eq:INVARIANTS_E_tot_vect}
\[
  % \label{eq:INVARIANTS_E_tot_vect_vor_2}
  \int\limits_D   \textbf{U}_h \cdot \text{VOR} \;dv   = 0
\]
\[
  % \label{eq:INVARIANTS_E_tot_vect_adv_2}
  \int\limits_D  \textbf{U}_h \cdot \text{KEG}  \;dv
  + \int\limits_D  \textbf{U}_h \cdot \text{ZAD}  \;dv
  -  \int\limits_D { \frac{{\textbf{U}_h}^2}{2} \frac{1}{e_3} \partial_t e_3 \;dv }   = 0
\]
\[
  % \label{eq:INVARIANTS_E_tot_pg_2}
  - \int\limits_D  \textbf{U}_h \cdot (\text{HPG}+ \text{SPG}) \;dv
  = - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
  + \int\limits_D g\, \rho \; \partial_t z  \;dv
\]

Flux form:
\begin{subequations}
  \label{eq:INVARIANTS_E_tot_flux}
  \[
    % \label{eq:INVARIANTS_E_tot_flux_metric_2}
    \int\limits_D  \textbf{U}_h \cdot \text {COR} \;  dv   = 0
  \]
  \[
    % \label{eq:INVARIANTS_E_tot_flux_adv_2}
    \int\limits_D \textbf{U}_h \cdot \text{ADV}   \;dv
    +   \frac{1}{2} \int\limits_D {  {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t e_3  \;dv } =\;0
  \]
  \begin{equation}
    \label{eq:INVARIANTS_E_tot_pg_3}
    - \int\limits_D  \textbf{U}_h \cdot (\text{HPG}+ \text{SPG}) \;dv
    = - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
    + \int\limits_D g\, \rho \; \partial_t  z  \;dv
  \end{equation}
\end{subequations}

\autoref{eq:INVARIANTS_E_tot_pg_3} is the balance between the conversion KE to PE and PE to KE.
Indeed the left hand side of \autoref{eq:INVARIANTS_E_tot_pg_3} can be transformed as follows:
\begin{flalign*}
  \partial_t  \left( \int\limits_D { \rho \, g \, z  \;dv} \right)
  &= + \int\limits_D \frac{1}{e_3} \partial_t (e_3\,\rho) \;g\;z\;\;dv
  +  \int\limits_D g\, \rho \; \partial_t z  \;dv   &&&\\
  &= - \int\limits_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
  + \int\limits_D g\, \rho \; \partial_t z \;dv   &&&\\
  &= + \int\limits_D  \rho \,g \left( \textbf {U}_h \cdot \nabla_h z + \omega \frac{1}{e_3} \partial_k z \right)  \;dv
  + \int\limits_D g\, \rho \; \partial_t z \;dv   &&&\\
  &= + \int\limits_D  \rho \,g \left( \omega + \partial_t z + \textbf {U}_h \cdot \nabla_h z  \right)  \;dv  &&&\\
  &=+  \int\limits_D g\, \rho \; w \; dv   &&&\\
\end{flalign*}
where the last equality is obtained by noting that the brackets is exactly the expression of $w$,
the vertical velocity referenced to the fixe $z$-coordinate system (see \autoref{eq:SCOORD_w_s}).

The left hand side of \autoref{eq:INVARIANTS_E_tot_pg_3} can be transformed as follows:
\begin{flalign*}
  - \int\limits_D  \left. \nabla p \right|_z & \cdot \textbf{U}_h \;dv
  = - \int\limits_D  \left( \nabla_h p + \rho \, g \nabla_h z \right) \cdot \textbf{U}_h \;dv   &&&\\
  \allowdisplaybreaks
  &= - \int\limits_D  \nabla_h  p \cdot \textbf{U}_h \;dv   - \int\limits_D  \rho \, g \, \nabla_h z \cdot \textbf{U}_h \;dv   &&&\\
  \allowdisplaybreaks
  &= +\int\limits_D p \,\nabla_h \cdot \textbf{U}_h \;dv   + \int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
  \allowdisplaybreaks
  &= -\int\limits_D p \left( \frac{1}{e_3} \partial_t e_3 + \frac{1}{e_3} \partial_k \omega  \right) \;dv
  +\int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
  \allowdisplaybreaks
  &= -\int\limits_D \frac{p}{e_3} \partial_t e_3  \;dv
  +\int\limits_D \frac{1}{e_3} \partial_k p\; \omega \;dv
  +\int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
  &= -\int\limits_D \frac{p}{e_3} \partial_t e_3  \;dv
  -\int\limits_D \rho \, g \, \omega \;dv
  +\int\limits_D  \rho \, g \left( \omega - w + \partial_t z \right) \;dv   &&&\\
  &= - \int\limits_D \frac{p}{e_3} \partial_t e_3 \; \;dv
  - \int\limits_D  \rho \, g \, w \;dv
  + \int\limits_D   \rho \, g \, \partial_t z \;dv   &&&\\
  \allowdisplaybreaks
  \intertext{introducing the hydrostatic balance $\partial_k p=-\rho \,g\,e_3$ in the last term,
    it becomes:}
  &= - \int\limits_D \frac{p}{e_3} \partial_t e_3 \;dv
  - \int\limits_D  \rho \, g \, w \;dv
  - \int\limits_D  \frac{1}{e_3} \partial_k p\, \partial_t z \;dv   &&&\\
  &= - \int\limits_D \frac{p}{e_3} \partial_t e_3 \;dv
  - \int\limits_D  \rho \, g \, w \;dv
  + \int\limits_D \,\frac{p}{e_3}\partial_t ( \partial_k z )  dv   &&&\\
  %
  &= - \int\limits_D  \rho \, g \, w \;dv   &&&\\
\end{flalign*}

%gm comment
\cmtgm{
The last equality comes from the following equation,
\begin{flalign*}
  \int\limits_D p \frac{1}{e_3} \frac{\partial e_3}{\partial t}\; \;dv
  = \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv \quad,
\end{flalign*}
that can be demonstrated as follows:

\begin{flalign*}
  \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv
  &= \int\limits_D    \rho \, g \, \frac{\partial \eta}{\partial t} \;dv
  -  \int\limits_D    \rho \, g \, \frac{\partial}{\partial t} \left(  \int\limits_k^{k_s}  e_3 \;d\tilde{k} \right) \;dv   &&&\\
  &= \int\limits_D    \rho \, g \, \frac{\partial \eta}{\partial t} \;dv
  -  \int\limits_D    \rho \, g    \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right) \;dv   &&&\\
  %
  \allowdisplaybreaks
  \intertext{The second term of the right hand side can be transformed by applying the integration by part rule:
    $\left[ a\,b \right]_{k_b}^{k_s} = \int_{k_b}^{k_s}  a\,\frac{\partial b}{\partial k}       \;dk
    + \int_{k_b}^{k_s}      \frac{\partial a}{\partial k} \,b \;dk $
    to the following function: $a=  \int_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k}$
    and $b=  \int_k^{k_s}  \rho \, e_3 \;d\tilde{k}$
    (note that $\frac{\partial}{\partial k} \left(  \int_k^{k_s}  a \;d\tilde{k}  \right) = - a$ as $k$ is the lower bound of the integral).
    This leads to:  }
\end{flalign*}
\begin{flalign*}
  &\left[ \int\limits_{k}^{k_s}  \frac{\partial e_3}{\partial t} \,dk \cdot \int\limits_{k}^{k_s}  \rho \, e_3 \,dk   \right]_{k_b}^{k_s}
  =-\int\limits_{k_b}^{k_s} \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right)  \rho \,e_3 \;dk
  -\int\limits_{k_b}^{k_s}  \frac{\partial e_3}{\partial t}  \left(  \int\limits_k^{k_s}  \rho \, e_3 \;d\tilde{k} \right)   dk  &&&\\
  \allowdisplaybreaks
  \intertext{Noting that $\frac{\partial \eta}{\partial t}
    = \frac{\partial}{\partial t}  \left( \int_{k_b}^{k_s}   e_3  \;d\tilde{k}  \right)
    = \int_{k_b}^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k}$
    and
    $p(k) = \int_k^{k_s}  \rho \,g \, e_3 \;d\tilde{k} $,
    but also that $\frac{\partial \eta}{\partial t}$ does not depends on $k$, it comes:
  }
  & - \int\limits_{k_b}^{k_s}  \rho \, \frac{\partial \eta}{\partial t} \, e_3 \;dk
  = - \int\limits_{k_b}^{k_s} \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right)   \, \rho \, g   e_3\;dk
  - \int\limits_{k_b}^{k_s}  \frac{\partial e_3}{\partial t} \frac{p}{g}         \;dk       &&&\\
\end{flalign*}
Mutliplying by $g$ and integrating over the $(i,j)$ domain it becomes:
\begin{flalign*}
  \int\limits_D  \rho \, g \, \left(  \int\limits_k^{k_s}  \frac{\partial e_3}{\partial t} \;d\tilde{k} \right)    \;dv
  =  \int\limits_D  \rho \, g \, \frac{\partial \eta}{\partial t} dv
  - \int\limits_D  \frac{p}{e_3}\frac{\partial e_3}{\partial t}         \;dv
\end{flalign*}
Using this property, we therefore have:
\begin{flalign*}
  \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv
  &= \int\limits_D    \rho \, g \, \frac{\partial \eta}{\partial t}   \;dv
  - \left(  \int\limits_D  \rho \, g \, \frac{\partial \eta}{\partial t} dv
    - \int\limits_D  \frac{p}{e_3}\frac{\partial e_3}{\partial t}   \;dv  \right)    &&&\\
  %
  &=\int\limits_D \frac{p}{e_3} \frac{\partial (e_3\,\rho)}{\partial t}\; \;dv
\end{flalign*}
% end gm comment
}

%% =================================================================================================
\section{Discrete total energy conservation: vector invariant form}
\label{sec:INVARIANTS_2}

%% =================================================================================================
\subsection{Total energy conservation}
\label{subsec:INVARIANTS_KE+PE_vect}

The discrete form of the total energy conservation, \autoref{eq:INVARIANTS_Tot_Energy}, is given by:
\begin{flalign*}
  \partial_t  \left(  \sum\limits_{i,j,k} \biggl\{ \frac{u^2}{2} \,b_u + \frac{v^2}{2}\, b_v +  \rho \, g \, z_t \,b_t  \biggr\} \right) &=0
\end{flalign*}
which in vector invariant forms, it leads to:
\begin{equation}
  \label{eq:INVARIANTS_KE+PE_vect_discrete}
  \begin{split}
    \sum\limits_{i,j,k} \biggl\{   u\,                        \partial_t u         \;b_u
    + v\,                        \partial_t v          \;b_v  \biggr\}
    + \frac{1}{2} \sum\limits_{i,j,k} \biggl\{  \frac{u^2}{e_{3u}}\partial_t e_{3u} \;b_u
    +  \frac{v^2}{e_{3v}}\partial_t e_{3v} \;b_v   \biggr\}      \\
    = - \sum\limits_{i,j,k} \biggl\{ \frac{1}{e_{3t}}\partial_t (e_{3t} \rho) \, g \, z_t \;b_t  \biggr\}
    - \sum\limits_{i,j,k} \biggl\{ \rho \,g\,\partial_t (z_t) \,b_t  \biggr\}
  \end{split}
\end{equation}

Substituting the discrete expression of the time derivative of the velocity either in vector invariant,
leads to the discrete equivalent of the four equations \autoref{eq:INVARIANTS_E_tot_flux}.

%% =================================================================================================
\subsection{Vorticity term (coriolis + vorticity part of the advection)}
\label{subsec:INVARIANTS_vor}

Let $q$, located at $f$-points, be either the relative ($q=\zeta / e_{3f}$),
or the planetary ($q=f/e_{3f}$), or the total potential vorticity ($q=(\zeta +f) /e_{3f}$).
Two discretisation of the vorticity term (ENE and EEN) allows the conservation of the kinetic energy.
%% =================================================================================================
\subsubsection{Vorticity term with ENE scheme (\protect\np[=.true.]{ln_dynvor_ene}{ln\_dynvor\_ene})}
\label{subsec:INVARIANTS_vorENE}

For the ENE scheme, the two components of the vorticity term are given by:
\[
  - e_3 \, q \;{\textbf{k}}\times {\textbf {U}}_h    \equiv
  \left( {{
        \begin{array} {*{20}c}
          + \frac{1} {e_{1u}} \;
          \overline {\, q \ \overline {\left( e_{1v}\,e_{3v}\,v \right)}^{\,i+1/2}} ^{\,j}        \hfill \\
          - \frac{1} {e_{2v}} \;
          \overline {\, q \ \overline {\left( e_{2u}\,e_{3u}\,u \right)}^{\,j+1/2}} ^{\,i}       \hfill
        \end{array}
      } }    \right)
\]

This formulation does not conserve the enstrophy but it does conserve the total kinetic energy.
Indeed, the kinetic energy tendency associated to the vorticity term and
averaged over the ocean domain can be transformed as follows:
\begin{flalign*}
  &\int\limits_D -  \left(  e_3 \, q \;\textbf{k} \times \textbf{U}_h  \right) \cdot \textbf{U}_h  \;  dv &&  \\
  & \qquad \qquad
  {
    \begin{array}{*{20}l}
      &\equiv \sum\limits_{i,j,k} 	\biggl\{
        \frac{1} {e_{1u}} \overline { \,q\ \overline{ V }^{\,i+1/2}} ^{\,j} \, u \; b_u
        - \frac{1} {e_{2v}}\overline { \, q\ \overline{ U }^{\,j+1/2}} ^{\,i} \, v \; b_v \; \biggr\}    \\
      &\equiv  \sum\limits_{i,j,k} 	\biggl\{
        \overline { \,q\ \overline{ V }^{\,i+1/2}}^{\,j} \; U
        - \overline { \,q\ \overline{ U }^{\,j+1/2}}^{\,i} \; V  \; \biggr\}     \\
      &\equiv \sum\limits_{i,j,k} q \  \biggl\{  \overline{ V }^{\,i+1/2}\; \overline{ U }^{\,j+1/2}
        - \overline{ U }^{\,j+1/2}\; \overline{ V }^{\,i+1/2}         \biggr\}  \quad  \equiv 0
    \end{array}
  }
\end{flalign*}
In other words, the domain averaged kinetic energy does not change due to the vorticity term.

%% =================================================================================================
\subsubsection{Vorticity term with EEN scheme (\protect\np[=.true.]{ln_dynvor_een}{ln\_dynvor\_een})}
\label{subsec:INVARIANTS_vorEEN_vect}

With the EEN scheme, the vorticity terms are represented as:
\begin{equation}
  \label{eq:INVARIANTS_dynvor_een1}
  \left\{ {
      \begin{aligned}
        +q\,e_3 \, v 	&\equiv +\frac{1}{e_{1u} }   \sum_{\substack{i_p,\,k_p}}
        {^{i+1/2-i_p}_j}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{1v} e_{3v} \ v  \right)^{i+i_p-1/2}_{j+j_p}   \\
        - q\,e_3 \, u     &\equiv -\frac{1}{e_{2v} }    \sum_{\substack{i_p,\,k_p}}
        {^i_{j+1/2-j_p}}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{2u} e_{3u} \ u  \right)^{i+i_p}_{j+j_p-1/2}
      \end{aligned}
    } \right.
\end{equation}
where the indices $i_p$ and $j_p$ take the following value: $i_p = -1/2$ or $1/2$ and $j_p = -1/2$ or $1/2$,
and the vorticity triads, ${^i_j}\mathbb{Q}^{i_p}_{j_p}$, defined at $T$-point, are given by:
\begin{equation}
  \label{eq:INVARIANTS_Q_triads}
  _i^j \mathbb{Q}^{i_p}_{j_p}
  = \frac{1}{12} \ \left(   q^{i-i_p}_{j+j_p} + q^{i+j_p}_{j+i_p} + q^{i+i_p}_{j-j_p}  \right)
\end{equation}

This formulation does conserve the total kinetic energy.
Indeed,
\begin{flalign*}
  &\int\limits_D - \textbf{U}_h \cdot   \left(  \zeta \;\textbf{k} \times \textbf{U}_h  \right)  \;  dv &&  \\
  \equiv \sum\limits_{i,j,k} &	\biggl\{
  \left[  \sum_{\substack{i_p,\,k_p}}
    {^{i+1/2-i_p}_j}\mathbb{Q}^{i_p}_{j_p} \; V^{i+1/2-i_p}_{j+j_p} \right] U^{i+1/2}_{j}    %   &&\\
  - \left[  \sum_{\substack{i_p,\,k_p}}
    {^i_{j+1/2-j_p}}\mathbb{Q}^{i_p}_{j_p} \; U^{i+i_p}_{j+1/2-j_p}  \right] V^{i}_{j+1/2}    \biggr\}     && \\ \\
  \equiv \sum\limits_{i,j,k} &  \sum_{\substack{i_p,\,k_p}} \biggl\{  \ \
  {^{i+1/2-i_p}_j}\mathbb{Q}^{i_p}_{j_p} \; V^{i+1/2-i_p}_{j+j_p}  \, U^{i+1/2}_{j}     %  &&\\
  - {^i_{j+1/2-j_p}}\mathbb{Q}^{i_p}_{j_p} \; U^{i+i_p}_{j+1/2-j_p} \, V^{i}_{j+1/2}     \ \;     \biggr\}     &&  \\
  %
  \allowdisplaybreaks
  \intertext{ Expending the summation on $i_p$ and $k_p$, it becomes:}
  %
  \equiv \sum\limits_{i,j,k} & \biggl\{  \ \
  {^{i+1}_j     }\mathbb{Q}^{-1/2}_{+1/2} \;V^{i+1}_{j+1/2} \; U^{\,i+1/2}_{j}
  -  {^i_{j}\quad}\mathbb{Q}^{-1/2}_{+1/2} \; U^{i-1/2}_{j}    \; V^{\,i}_{j+1/2}         &&  \\
  &       + {^{i+1}_j     }\mathbb{Q}^{-1/2}_{-1/2} \; V^{i+1}_{j-1/2} \; U^{\,i+1/2}_{j}
  - {^i_{j+1}     }\mathbb{Q}^{-1/2}_{-1/2} \; U^{i-1/2}_{j+1} \; V^{\,i}_{j+1/2}        \biggr.     &&  \\
  &       + {^{i}_j\quad}\mathbb{Q}^{+1/2}_{+1/2} \; V^{i}_{j+1/2}   \; U^{\,i+1/2}_{j}
  - {^i_{j}\quad}\mathbb{Q}^{+1/2}_{+1/2} \; U^{i+1/2}_{j}   \; V^{\,i}_{j+1/2}          \biggr.        &&  \\
  &       + {^{i}_j\quad}\mathbb{Q}^{+1/2}_{-1/2} \; V^{i}_{j-1/2}     \; U^{\,i+1/2}_{j}
  -  {^i_{j+1}     }\mathbb{Q}^{+1/2}_{-1/2} \; U^{i+1/2}_{j+1}\; V^{\,i}_{j+1/2}  \ \;     \biggr\}     &&  \\
  %
  \allowdisplaybreaks
  \intertext{The summation is done over all $i$ and $j$ indices, it is therefore possible to introduce
    a shift of $-1$ either in $i$ or $j$ direction in some of the term of the summation (first term of the
    first and second lines, second term of the second and fourth lines). By doning so, we can regroup
    all the terms of the summation by triad at a ($i$,$j$) point. In other words, we regroup all the terms
    in the neighbourhood  that contain a triad at the same ($i$,$j$) indices. It becomes: }
  \allowdisplaybreaks
  %
  \equiv \sum\limits_{i,j,k} & \biggl\{  \ \
  {^{i}_j}\mathbb{Q}^{-1/2}_{+1/2}  \left[  V^{i}_{j+1/2}\, U^{\,i-1/2}_{j}
    -  U^{i-1/2}_{j} \, V^{\,i}_{j+1/2}      \right]    &&  \\
  &       + {^{i}_j}\mathbb{Q}^{-1/2}_{-1/2}  \left[  V^{i}_{j-1/2} \, U^{\,i-1/2}_{j}
    -    U^{i-1/2}_{j} \, V^{\,i}_{j-1/2}      \right]    \biggr.   &&  \\
  &      + {^{i}_j}\mathbb{Q}^{+1/2}_{+1/2}  \left[  V^{i}_{j+1/2} \, U^{\,i+1/2}_{j}
    -    U^{i+1/2}_{j} \, V^{\,i}_{j+1/2}     \right]  \biggr.  &&  \\
  &     + {^{i}_j}\mathbb{Q}^{+1/2}_{-1/2}  \left[   V^{i}_{j-1/2} \, U^{\,i+1/2}_{j}
    -    U^{i+1/2}_{j-1} \, V^{\,i}_{j-1/2}  \right]  \ \;   \biggr\}   \qquad
  \equiv \ 0   &&
\end{flalign*}

%% =================================================================================================
\subsubsection{Gradient of kinetic energy / Vertical advection}
\label{subsec:INVARIANTS_zad}

The change of Kinetic Energy (KE) due to the vertical advection is exactly balanced by the change of KE due to the horizontal gradient of KE~:
\[
  \int_D \textbf{U}_h \cdot \frac{1}{e_3 } \omega \partial_k \textbf{U}_h \;dv
  =  -   \int_D \textbf{U}_h \cdot \nabla_h \left( \frac{1}{2}\;{\textbf{U}_h}^2 \right)\;dv
  +   \frac{1}{2} \int_D {  \frac{{\textbf{U}_h}^2}{e_3} \partial_t ( e_3) \;dv }
\]
Indeed, using successively \autoref{eq:DOM_di_adj} (\ie\ the skew symmetry property of the $\delta$ operator)
and the continuity equation, then \autoref{eq:DOM_di_adj} again,
then the commutativity of operators $\overline {\,\cdot \,}$ and $\delta$, and finally \autoref{eq:DOM_mi_adj}
(\ie\ the symmetry property of the $\overline {\,\cdot \,}$ operator)
applied in the horizontal and vertical directions, it becomes:
\begin{flalign*}
  & - \int_D \textbf{U}_h \cdot \text{KEG}\;dv
  = - \int_D \textbf{U}_h \cdot \nabla_h \left( \frac{1}{2}\;{\textbf{U}_h}^2 \right)\;dv    &&&\\
  %
  \equiv  & -  \sum\limits_{i,j,k} \frac{1}{2}  \biggl\{
  \frac{1} {e_{1u}}  \delta_{i+1/2}   \left[   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right]  u \ b_u
  + \frac{1} {e_{2v}}  \delta_{j+1/2}   \left[   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right]  v \ b_v   \biggr\}  	&&&  \\
  %
  \equiv & + \sum\limits_{i,j,k} \frac{1}{2}  \left(   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right)\;
  \biggl\{ \delta_{i} \left[  U   \right] +  \delta_{j} \left[  V  \right]    \biggr\}       &&&  \\
  \allowdisplaybreaks
  %
  \equiv   & - \sum\limits_{i,j,k}  \frac{1}{2}
  \left(       \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right)  \;
  \biggl\{   \frac{b_t}{e_{3t}} \partial_t (e_{3t})  +  \delta_k \left[  W   \right]    \biggr\}    &&&\\
  \allowdisplaybreaks
  %
  \equiv & +  \sum\limits_{i,j,k} \frac{1}{2} \delta_{k+1/2}   \left[ \overline{ u^2}^{\,i} + \overline{ v^2}^{\,j}   \right] \;  W
  -  \sum\limits_{i,j,k} \frac{1}{2} \left(   \overline {u^2}^{\,i} + \overline {v^2}^{\,j}   \right) \;\partial_t b_t   &&& \\
  \allowdisplaybreaks
  %
  \equiv   & + \sum\limits_{i,j,k} \frac{1} {2} \left(    \overline{\delta_{k+1/2} \left[ u^2 \right]}^{\,i}
    + \overline{\delta_{k+1/2} \left[ v^2 \right]}^{\,j}    \right) \; W
  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t \overline{b_t}^{\,{i+1/2}}
    + \frac{v^2}{2}\,\partial_t \overline{b_t}^{\,{j+1/2}}   \right)    &&& \\
  \allowdisplaybreaks
  \intertext{Assuming that $b_u= \overline{b_t}^{\,i+1/2}$ and $b_v= \overline{b_t}^{\,j+1/2}$, or at least that the time
    derivative of these two equations is satisfied, it becomes:}
  %
  \equiv &     \sum\limits_{i,j,k} \frac{1} {2}
  \biggl\{ \; \overline{W}^{\,i+1/2}\;\delta_{k+1/2} \left[ u^2 \right]
  + \overline{W}^{\,j+1/2}\;\delta_{k+1/2} \left[ v^2 \right]  \;  \biggr\}
  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t b_u
    + \frac{v^2}{2}\,\partial_t b_v   \right)    &&& \\
  \allowdisplaybreaks
  %
  \equiv &     \sum\limits_{i,j,k}
  \biggl\{ \; \overline{W}^{\,i+1/2}\; \overline {u}^{\,k+1/2}\; \delta_{k+1/2}[ u ]
  + \overline{W}^{\,j+1/2}\; \overline {v}^{\,k+1/2}\; \delta_{k+1/2}[ v ]  \;  \biggr\}
  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t b_u
    + \frac{v^2}{2}\,\partial_t b_v   \right)    &&& \\
  %
  \allowdisplaybreaks
  \equiv  &  \sum\limits_{i,j,k}
  \biggl\{ \; \frac{1} {b_u } \; \overline { \overline{W}^{\,i+1/2}\,\delta_{k+1/2}  \left[ u \right] }^{\,k} \;u\;b_u
  + \frac{1} {b_v } \; \overline { \overline{W}^{\,j+1/2} \delta_{k+1/2}  \left[ v \right]  }^{\,k} \;v\;b_v  \; \biggr\}
  -  \sum\limits_{i,j,k}  \left(  \frac{u^2}{2}\,\partial_t b_u
    + \frac{v^2}{2}\,\partial_t b_v   \right)    &&& \\
  %
  \intertext{The first term provides the discrete expression for the vertical advection of momentum (ZAD),
    while the second term corresponds exactly to \autoref{eq:INVARIANTS_KE+PE_vect_discrete}, therefore:}
  \equiv&                   \int\limits_D \textbf{U}_h \cdot \text{ZAD} \;dv
  + \frac{1}{2} \int_D { {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t  (e_3)  \;dv }    &&&\\
  \equiv&                   \int\limits_D \textbf{U}_h \cdot w \partial_k \textbf{U}_h \;dv
  + \frac{1}{2} \int_D { {\textbf{U}_h}^2 \frac{1}{e_3} \partial_t  (e_3)  \;dv }    &&&\\
\end{flalign*}

There is two main points here.
First, the satisfaction of this property links the choice of the discrete formulation of the vertical advection and
of the horizontal gradient of KE.
Choosing one imposes the other.
For example KE can also be discretized as $1/2\,({\overline u^{\,i}}^2 + {\overline v^{\,j}}^2)$.
This leads to the following expression for the vertical advection:
\[
  \frac{1} {e_3 }\; \omega\; \partial_k \textbf{U}_h
  \equiv \left( {{
        \begin{array} {*{20}c}
          \frac{1} {e_{1u}\,e_{2u}\,e_{3u}} \;  \overline{\overline {e_{1t}\,e_{2t} \,\omega\;\delta_{k+1/2}
          \left[ \overline u^{\,i+1/2} \right]}}^{\,i+1/2,k}  \hfill \\
          \frac{1} {e_{1v}\,e_{2v}\,e_{3v}} \;   \overline{\overline {e_{1t}\,e_{2t} \,\omega \;\delta_{k+1/2}
          \left[ \overline v^{\,j+1/2} \right]}}^{\,j+1/2,k} \hfill
        \end{array}
      } } \right)
\]
a formulation that requires an additional horizontal mean in contrast with the one used in \NEMO.
Nine velocity points have to be used instead of 3.
This is the reason why it has not been chosen.

Second, as soon as the chosen $s$-coordinate depends on time,
an extra constraint arises on the time derivative of the volume at $u$- and $v$-points:
\begin{flalign*}
  e_{1u}\,e_{2u}\,\partial_t (e_{3u}) =\overline{ e_{1t}\,e_{2t}\;\partial_t (e_{3t}) }^{\,i+1/2}    \\
  e_{1v}\,e_{2v}\,\partial_t (e_{3v})  =\overline{ e_{1t}\,e_{2t}\;\partial_t (e_{3t}) }^{\,j+1/2}
\end{flalign*}
which is (over-)satified by defining the vertical scale factor as follows:
\begin{flalign*}
  % \label{eq:INVARIANTS_e3u-e3v}
  e_{3u} = \frac{1}{e_{1u}\,e_{2u}}\;\overline{ e_{1t}^{ }\,e_{2t}^{ }\,e_{3t}^{ } }^{\,i+1/2}    \\
  e_{3v} = \frac{1}{e_{1v}\,e_{2v}}\;\overline{ e_{1t}^{ }\,e_{2t}^{ }\,e_{3t}^{ } }^{\,j+1/2}
\end{flalign*}

Blah blah required on the the step representation of bottom topography.....

%% =================================================================================================
\subsection{Pressure gradient term}
\label{subsec:INVARIANTS_2.6}

\cmtgm{
  A pressure gradient has no contribution to the evolution of the vorticity as the curl of a gradient is zero.
  In the $z$-coordinate, this property is satisfied locally on a C-grid with 2nd order finite differences
  (property \autoref{eq:DOM_curl_grad}).
}

When the equation of state is linear
(\ie\ when an advection-diffusion equation for density can be derived from those of temperature and salinity)
the change of KE due to the work of pressure forces is balanced by
the change of potential energy due to buoyancy forces:
\[
  - \int_D  \left. \nabla p \right|_z \cdot \textbf{U}_h \;dv
  = - \int_D \nabla \cdot \left( \rho \,\textbf {U} \right) \,g\,z \;dv
  + \int_D g\, \rho \; \partial_t (z)  \;dv
\]

This property can be satisfied in a discrete sense for both $z$- and $s$-coordinates.
Indeed, defining the depth of a $T$-point, $z_t$,
as the sum of the vertical scale factors at $w$-points starting from the surface,
the work of pressure forces can be written as:
\begin{flalign*}
  &- \int_D  \left. \nabla p \right|_z \cdot \textbf{U}_h \;dv
  \equiv \sum\limits_{i,j,k} \biggl\{ \;  - \frac{1} {e_{1u}}   \Bigl(
  \delta_{i+1/2} [p_t] - g\;\overline \rho^{\,i+1/2}\;\delta_{i+1/2} [z_t]     \Bigr)  \; u\;b_u && \\
  & \qquad \qquad  \qquad \qquad  \qquad \quad \ \,
  - \frac{1} {e_{2v}}    \Bigl(
  \delta_{j+1/2} [p_t] - g\;\overline \rho^{\,j+1/2}\delta_{j+1/2} [z_t]      \Bigr)  \; v\;b_v \;  \biggr\}   && \\
  %
  \allowdisplaybreaks
  \intertext{Using successively \autoref{eq:DOM_di_adj}, \ie\ the skew symmetry property of
    the $\delta$ operator, \autoref{eq:DYN_wzv}, the continuity equation, \autoref{eq:DYN_hpg_sco},
    the hydrostatic equation in the $s$-coordinate, and $\delta_{k+1/2} \left[ z_t \right] \equiv e_{3w} $,
    which comes from the definition of $z_t$, it becomes: }
  \allowdisplaybreaks
  %
  \equiv& +  \sum\limits_{i,j,k}   g  \biggl\{
  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
  +\Bigl(  \delta_i[U] + \delta_j [V]  \Bigr)\;\frac{p_t}{g} \biggr\}  &&\\
  %
  \equiv& +  \sum\limits_{i,j,k}   g   \biggl\{
  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
  -       \left(   \frac{b_t}{e_{3t}} \partial_t (e_{3t})  +  \delta_k \left[ W \right]    \right) \frac{p_t}{g}    \biggr\}   &&&\\
  %
  \equiv& +  \sum\limits_{i,j,k}  g   \biggl\{
  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
  +	\frac{W}{g}\;\delta_{k+1/2} [p_t]
  -        \frac{p_t}{g}\,\partial_t b_t    \biggr\}    &&&\\
  %
  \equiv& +  \sum\limits_{i,j,k}  g   \biggl\{
  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
  - 	W\;e_{3w} \overline \rho^{\,k+1/2}
  -        \frac{p_t}{g}\,\partial_t b_t    \biggr\}    &&&\\
  %
  \equiv& +  \sum\limits_{i,j,k}    g   \biggl\{
  \overline\rho^{\,i+1/2}\,U\,\delta_{i+1/2}[z_t]
  +  	\overline\rho^{\,j+1/2}\,V\,\delta_{j+1/2}[z_t]
  + 	W\; \overline \rho^{\,k+1/2}\;\delta_{k+1/2} [z_t]
  -        \frac{p_t}{g}\,\partial_t b_t    \biggr\}    &&&\\
  %
  \allowdisplaybreaks
  %
  \equiv& - \sum\limits_{i,j,k}   g \; z_t      \biggl\{
  \delta_i 	\left[ U\;	\overline \rho^{\,i+1/2} 	\right]
  + 	\delta_j 	\left[ V\;	\overline \rho^{\,j+1/2} 	\right]
  + 	\delta_k 	\left[ W\;	\overline \rho^{\,k+1/2} 	\right]       \biggr\}
  - \sum\limits_{i,j,k}       \biggl\{ p_t\;\partial_t b_t    \biggr\}   &&&\\
  %
  \equiv& + \sum\limits_{i,j,k}   g \; z_t    \biggl\{      \partial_t ( e_{3t} \,\rho)    \biggr\}  \; b_t
  -  \sum\limits_{i,j,k}                 \biggl\{  p_t\;\partial_t b_t                     \biggr\}              &&&\\
  %
\end{flalign*}
The first term is exactly the first term of the right-hand-side of \autoref{eq:INVARIANTS_KE+PE_vect_discrete}.
It remains to demonstrate that the last term,
which is obviously a discrete analogue of $\int_D \frac{p}{e_3} \partial_t (e_3)\;dv$ is equal to
the last term of \autoref{eq:INVARIANTS_KE+PE_vect_discrete}.
In other words, the following property must be satisfied:
\begin{flalign*}
  \sum\limits_{i,j,k}  \biggl\{  p_t\;\partial_t b_t                  \biggr\}
  \equiv  \sum\limits_{i,j,k}  \biggl\{ \rho \,g\,\partial_t (z_t) \,b_t  \biggr\}
\end{flalign*}

Let introduce $p_w$ the pressure at $w$-point such that $\delta_k [p_w] = - \rho \,g\,e_{3t}$.
The right-hand-side of the above equation can be transformed as follows:

\begin{flalign*}
  \sum\limits_{i,j,k}  \biggl\{ \rho \,g\,\partial_t (z_t) \,b_t  \biggr\}
  &\equiv   - \sum\limits_{i,j,k}  \biggl\{ \delta_k [p_w]\,\partial_t (z_t) \,e_{1t}\,e_{2t}  \biggr\}        &&&\\
  %
  &\equiv  + \sum\limits_{i,j,k}  \biggl\{  p_w\, \delta_{k+1/2} [\partial_t (z_t)] \,e_{1t}\,e_{2t}  \biggr\}
  \equiv  + \sum\limits_{i,j,k}  \biggl\{  p_w\, \partial_t (e_{3w}) \,e_{1t}\,e_{2t}  \biggr\}        &&&\\
  &\equiv  + \sum\limits_{i,j,k}  \biggl\{  p_w\, \partial_t (b_w) \biggr\}
  %
  % & \equiv     \sum\limits_{i,j,k} \biggl\{  \frac{1}{e_{3t}} \delta_k [p_w]\;\partial_t (z_t) \,b_w   \right)   \biggr\}           &&&\\
  % & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t \left(    \delta_k [z_t]   \right)  e_{1w}\,e_{2w}   \biggr\}           &&&\\
  % & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t b_w   \biggr\}
\end{flalign*}
therefore, the balance to be satisfied is:
\begin{flalign*}
  \sum\limits_{i,j,k}  \biggl\{  p_t\;\partial_t (b_t) \biggr\}  \equiv  \sum\limits_{i,j,k}  \biggl\{  p_w\, \partial_t (b_w) \biggr\}
\end{flalign*}
which is a purely vertical balance:
\begin{flalign*}
  \sum\limits_{k}  \biggl\{  p_t\;\partial_t (e_{3t}) \biggr\}  \equiv  \sum\limits_{k}  \biggl\{  p_w\, \partial_t (e_{3w}) \biggr\}
\end{flalign*}
Defining $p_w = \overline{p_t}^{\,k+1/2}$

%gm comment
\cmtgm{
  \begin{flalign*}
    \sum\limits_{i,j,k} \biggl\{   p_t\;\partial_t b_t   \biggr\}                                &&&\\
    %
    & \equiv     \sum\limits_{i,j,k} \biggl\{  \frac{1}{e_{3t}} \delta_k [p_w]\;\partial_t (z_t) \,b_w    \biggr\}           &&&\\
    & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t \left(    \delta_{k+1/2} [z_t]   \right)  e_{1w}\,e_{2w}   \biggr\}           &&&\\
    & \equiv     \sum\limits_{i,j,k} \biggl\{   p_w\;\partial_t b_w   \biggr\}
  \end{flalign*}

  \begin{flalign*}
    \int\limits_D   \rho \, g \, \frac{\partial z }{\partial t} \;dv
    \equiv&  \sum\limits_{i,j,k}   \biggl\{  \frac{1}{e_{3t}} \frac{\partial e_{3t}}{\partial t} p   \biggr\} \; b_t   &&&\\
    \equiv&  \sum\limits_{i,j,k}   \biggl\{      \biggr\} \; b_t   &&&\\
  \end{flalign*}

  %
  \begin{flalign*}
    \equiv& - \int_D \nabla \cdot \left( \rho \,\textbf {U} \right)\;g\;z\;\;dv
    + \int\limits_D g\, \rho \; \frac{\partial z}{\partial t}  \;dv     &&& \\
  \end{flalign*}
  %
}
%end gm comment

Note that this property strongly constrains the discrete expression of both the depth of $T-$points and
of the term added to the pressure gradient in the $s$-coordinate.
Nevertheless, it is almost never satisfied since a linear equation of state is rarely used.

%% =================================================================================================
\section{Discrete total energy conservation: flux form}
\label{sec:INVARIANTS_3}

%% =================================================================================================
\subsection{Total energy conservation}
\label{subsec:INVARIANTS_KE+PE_flux}

The discrete form of the total energy conservation, \autoref{eq:INVARIANTS_Tot_Energy}, is given by:
\begin{flalign*}
  \partial_t \left(  \sum\limits_{i,j,k} \biggl\{ \frac{u^2}{2} \,b_u + \frac{v^2}{2}\, b_v +  \rho \, g \, z_t \,b_t  \biggr\} \right) &=0  \\
\end{flalign*}
which in flux form, it leads to:
\begin{flalign*}
  \sum\limits_{i,j,k} \biggl\{  \frac{u    }{e_{3u}}\,\frac{\partial (e_{3u}u)}{\partial t} \,b_u
  +  \frac{v    }{e_{3v}}\,\frac{\partial (e_{3v}v)}{\partial t} \,b_v  \biggr\}
  &  -  \frac{1}{2} \sum\limits_{i,j,k} \biggl\{  \frac{u^2}{e_{3u}}\frac{\partial    e_{3u}    }{\partial t} \,b_u
  +  \frac{v^2}{e_{3v}}\frac{\partial    e_{3v}    }{\partial t} \,b_v   \biggr\} \\
  &= - \sum\limits_{i,j,k} \biggl\{ \frac{1}{e_3t}\frac{\partial e_{3t} \rho}{\partial t} \, g \, z_t \,b_t  \biggr\}
  - \sum\limits_{i,j,k} \biggl\{ \rho \,g\,\frac{\partial z_t}{\partial t} \,b_t  \biggr\} \\
\end{flalign*}

Substituting the discrete expression of the time derivative of the velocity either in
vector invariant or in flux form, leads to the discrete equivalent of the ????

%% =================================================================================================
\subsection{Coriolis and advection terms: flux form}
\label{subsec:INVARIANTS_3.2}

%% =================================================================================================
\subsubsection{Coriolis plus ``metric'' term}
\label{subsec:INVARIANTS_3.3}

In flux from the vorticity term reduces to a Coriolis term in which
the Coriolis parameter has been modified to account for the ``metric'' term.
This altered Coriolis parameter is discretised at an f-point.
It is given by:
\[
  f+\frac{1} {e_1 e_2 } \left( v \frac{\partial e_2 } {\partial i} - u \frac{\partial e_1 } {\partial j}\right)\;
  \equiv \;
  f+\frac{1} {e_{1f}\,e_{2f}} \left( \overline v^{\,i+1/2} \delta_{i+1/2} \left[ e_{2u} \right]
    -\overline u^{\,j+1/2} \delta_{j+1/2} \left[ e_{1u}  \right] \right)
\]

Either the ENE or EEN scheme is then applied to obtain the vorticity term in flux form.
It therefore conserves the total KE.
The derivation is the same as for the vorticity term in the vector invariant form (\autoref{subsec:INVARIANTS_vor}).

%% =================================================================================================
\subsubsection{Flux form advection}
\label{subsec:INVARIANTS_3.4}

The flux form operator of the momentum advection is evaluated using
a centered second order finite difference scheme.
Because of the flux form, the discrete operator does not contribute to the global budget of linear momentum.
Because of the centered second order scheme, it conserves the horizontal kinetic energy, that is:

\begin{equation}
  \label{eq:INVARIANTS_ADV_KE_flux}
  -  \int_D \textbf{U}_h \cdot     \left(                 {{
        \begin{array} {*{20}c}
          \nabla \cdot \left( \textbf{U}\,u \right) \hfill \\
          \nabla \cdot \left( \textbf{U}\,v \right) \hfill \\
        \end{array}
      } }           \right)   \;dv
  -   \frac{1}{2} \int_D {  {\textbf{U}_h}^2 \frac{1}{e_3} \frac{\partial  e_3 }{\partial t} \;dv } =\;0
\end{equation}

Let us first consider the first term of the scalar product
(\ie\ just the the terms associated with the i-component of the advection):
\begin{flalign*}
  &  - \int_D u \cdot \nabla \cdot \left(   \textbf{U}\,u   \right) \; dv   \\
  %
  \equiv& - \sum\limits_{i,j,k} \biggl\{    \frac{1} {b_u}    \biggl(
  \delta_{i+1/2}  \left[   \overline {U}^{\,i}      \;\overline u^{\,i}          \right]
  + \delta_j           \left[   \overline {V}^{\,i+1/2}\;\overline u^{\,j+1/2}   \right]
  + \delta_k          \left[   \overline {W}^{\,i+1/2}\;\overline u^{\,k+1/2} \right]  \biggr)   \;   \biggr\} \, b_u \;u &&&  \\
  %
  \equiv& - \sum\limits_{i,j,k}
  \biggl\{
  \delta_{i+1/2} \left[   \overline {U}^{\,i}\;  \overline u^{\,i}  \right]
  + \delta_j          \left[   \overline {V}^{\,i+1/2}\;\overline u^{\,j+1/2}   \right]
  + \delta_k         \left[   \overline {W}^{\,i+12}\;\overline u^{\,k+1/2}  \right]
  \; \biggr\} \; u     \\
  %
  \equiv& + \sum\limits_{i,j,k}
  \biggl\{
  \overline {U}^{\,i}\;	\overline u^{\,i} 	\delta_i \left[ u \right]
  + \overline {V}^{\,i+1/2}\;	\overline u^{\,j+1/2} 	\delta_{j+1/2} \left[ u \right]
  + \overline {W}^{\,i+1/2}\;	\overline u^{\,k+1/2}	\delta_{k+1/2} 	\left[ u \right]     \biggr\}     && \\
  %
  \equiv& + \frac{1}{2} \sum\limits_{i,j,k}    \biggl\{
  \overline{U}^{\,i} 		\delta_i 		\left[ u^2 \right]
  + \overline{V}^{\,i+1/2} 	\delta_{j+/2} 	\left[ u^2 \right]
  + \overline{W}^{\,i+1/2} 	\delta_{k+1/2} 	\left[ u^2 \right]      \biggr\} && \\
  %
  \equiv& -  \sum\limits_{i,j,k}    \frac{1}{2}   \bigg\{
  U  \; \delta_{i+1/2}    \left[ \overline {u^2}^{\,i} \right]
  + V  \; \delta_{j+1/2}    \left[ \overline {u^2}^{\,i} \right]
  + W \; \delta_{k+1/2}   \left[ \overline {u^2}^{\,i} \right]     \biggr\}    &&& \\
  %
  \equiv& - \sum\limits_{i,j,k}  \frac{1}{2}  \overline {u^2}^{\,i}     \biggl\{
  \delta_{i+1/2} 	\left[ U  \right]
  + \delta_{j+1/2} 	\left[ V  \right]
  + \delta_{k+1/2} 	\left[ W \right]     \biggr\}    &&& \\
  %
  \equiv& + \sum\limits_{i,j,k}  \frac{1}{2}  \overline {u^2}^{\,i}
  \biggl\{     \left(   \frac{1}{e_{3t}} \frac{\partial e_{3t}}{\partial t}   \right) \; b_t     \biggr\}    &&& \\
\end{flalign*}
Applying similar manipulation applied to the second term of the scalar product leads to:
\[
  -  \int_D \textbf{U}_h \cdot     \left(                 {{
        \begin{array} {*{20}c}
          \nabla \cdot \left( \textbf{U}\,u \right) \hfill \\
          \nabla \cdot \left( \textbf{U}\,v \right) \hfill \\
        \end{array}
      } }           \right)   \;dv
  \equiv + \sum\limits_{i,j,k}  \frac{1}{2}  \left( \overline {u^2}^{\,i} + \overline {v^2}^{\,j} \right)
  \biggl\{     \left(   \frac{1}{e_{3t}} \frac{\partial e_{3t}}{\partial t}   \right) \; b_t     \biggr\}
\]
which is the discrete form of $ \frac{1}{2} \int_D u \cdot \nabla \cdot \left(   \textbf{U}\,u   \right) \; dv $.
\autoref{eq:INVARIANTS_ADV_KE_flux} is thus satisfied.

When the UBS scheme is used to evaluate the flux form momentum advection,
the discrete operator does not contribute to the global budget of linear momentum (flux form).
The horizontal kinetic energy is not conserved, but forced to decay (\ie\ the scheme is diffusive).

%% =================================================================================================
\section{Discrete enstrophy conservation}
\label{sec:INVARIANTS_4}

%% =================================================================================================
\subsubsection{Vorticity term with ENS scheme  (\protect\np[=.true.]{ln_dynvor_ens}{ln\_dynvor\_ens})}
\label{subsec:INVARIANTS_vorENS}

In the ENS scheme, the vorticity term is descretized as follows:
\begin{equation}
  \label{eq:INVARIANTS_dynvor_ens}
  \left\{
    \begin{aligned}
      +\frac{1}{e_{1u}} & \overline{q}^{\,i}  & {\overline{ \overline{\left( e_{1v}\,e_{3v}\;  v \right) } } }^{\,i, j+1/2}    \\
      - \frac{1}{e_{2v}} & \overline{q}^{\,j}  & {\overline{ \overline{\left( e_{2u}\,e_{3u}\; u \right) } } }^{\,i+1/2, j}
    \end{aligned}
  \right.
\end{equation}

The scheme does not allow but the conservation of the total kinetic energy but the conservation of $q^2$,
the potential enstrophy for a horizontally non-divergent flow (\ie\ when $\chi$=$0$).
Indeed, using the symmetry or skew symmetry properties of the operators
( \autoref{eq:DOM_mi_adj} and \autoref{eq:DOM_di_adj}),
it can be shown that:
\begin{equation}
  \label{eq:INVARIANTS_1.1}
  \int_D {q\,\;{\textbf{k}}\cdot \frac{1} {e_3} \nabla \times \left( {e_3 \, q \;{\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} \equiv 0
\end{equation}
where $dv=e_1\,e_2\,e_3 \; di\,dj\,dk$ is the volume element.
Indeed, using \autoref{eq:DYN_vor_ens},
the discrete form of the right hand side of \autoref{eq:INVARIANTS_1.1} can be transformed as follow:
\begin{flalign*}
  &\int_D q \,\; \textbf{k} \cdot \frac{1} {e_3 } \nabla \times
  \left(  e_3 \, q \; \textbf{k} \times  \textbf{U}_h   \right)\;   dv \\
  %
  & \qquad
  {
    \begin{array}{*{20}l}
      &\equiv \sum\limits_{i,j,k}
        q \ \left\{  \delta_{i+1/2}  \left[ - \,\overline {q}^{\,i}\;  \overline{\overline  U }^{\,i,j+1/ 2} \right]
        - \delta_{j+1/2} \left[	 \overline {q}^{\,j}\;  \overline{\overline  V }^{\,i+1/2, j} \right]     \right\}    \\
      %
      &\equiv \sum\limits_{i,j,k}
        \left\{   \delta_i [q] \; \overline{q}^{\,i} \; \overline{  \overline U  }^{\,i,j+1/2}
        + \delta_j [q] \; \overline{q}^{\,j} \; \overline{\overline V }^{\,i+1/2,j}        \right\}       &&  \\
      %
      &\equiv \,\frac{1} {2} \sum\limits_{i,j,k}
        \left\{         \delta_i  \left[ q^2 \right] \; \overline{\overline U }^{\,i,j+1/2}
        + \delta_j  \left[ q^2 \right] \; \overline{\overline V }^{\,i+1/2,j}      \right\}    &&  \\
      %
      &\equiv - \frac{1} {2} \sum\limits_{i,j,k} 	q^2 \;
        \left\{    \delta_{i+1/2}   \left[   \overline{\overline{ U }}^{\,i,j+1/2}    \right]
        + \delta_{j+1/2}  \left[   \overline{\overline{ V }}^{\,i+1/2,j}     \right]    \right\}    && \\
    \end{array}
  }
  %
  \allowdisplaybreaks
  \intertext{ Since $\overline {\;\cdot \;} $ and $\delta $ operators commute: $\delta_{i+1/2}
    \left[ {\overline a^{\,i}} \right] = \overline {\delta_i \left[ a \right]}^{\,i+1/2}$,
    and introducing the horizontal divergence $\chi $, it becomes: }
  \allowdisplaybreaks
  %
  & \qquad {
    \begin{array}{*{20}l}
      &\equiv \sum\limits_{i,j,k} - \frac{1} {2} q^2 \; \overline{\overline{ e_{1t}\,e_{2t}\,e_{3t}^{}\, \chi}}^{\,i+1/2,j+1/2}
        \quad \equiv 0 &&
    \end{array}
  }
\end{flalign*}
The later equality is obtain only when the flow is horizontally non-divergent, \ie\ $\chi$=$0$.

%% =================================================================================================
\subsubsection{Vorticity Term with EEN scheme (\protect\np[=.true.]{ln_dynvor_een}{ln\_dynvor\_een})}
\label{subsec:INVARIANTS_vorEEN}

With the EEN scheme, the vorticity terms are represented as:
\begin{equation}
  \label{eq:INVARIANTS_dynvor_een2}
  \left\{ {
      \begin{aligned}
        +q\,e_3 \, v 	&\equiv +\frac{1}{e_{1u} }   \sum_{\substack{i_p,\,k_p}}
        {^{i+1/2-i_p}_j}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{1v} e_{3v} \ v  \right)^{i+i_p-1/2}_{j+j_p}   \\
        - q\,e_3 \, u     &\equiv -\frac{1}{e_{2v} }    \sum_{\substack{i_p,\,k_p}}
        {^i_{j+1/2-j_p}}  \mathbb{Q}^{i_p}_{j_p}  \left( e_{2u} e_{3u} \ u  \right)^{i+i_p}_{j+j_p-1/2}   \\
      \end{aligned}
    } \right.
\end{equation}
where the indices $i_p$ and $k_p$ take the following values:
$i_p = -1/2$ or $1/2$ and $j_p = -1/2$ or $1/2$,
and the vorticity triads, ${^i_j}\mathbb{Q}^{i_p}_{j_p}$, defined at $T$-point, are given by:
\begin{equation}
  \tag{\ref{eq:INVARIANTS_Q_triads}}
  _i^j \mathbb{Q}^{i_p}_{j_p}
  = \frac{1}{12} \ \left(   q^{i-i_p}_{j+j_p} + q^{i+j_p}_{j+i_p} + q^{i+i_p}_{j-j_p}  \right)
\end{equation}

This formulation does conserve the potential enstrophy for a horizontally non-divergent flow (\ie\ $\chi=0$).

Let consider one of the vorticity triad, for example ${^{i}_j}\mathbb{Q}^{+1/2}_{+1/2} $,
similar manipulation can be done for the 3 others.
The discrete form of the right hand side of \autoref{eq:INVARIANTS_1.1} applied to
this triad only can be transformed as follow:

\begin{flalign*}
  &\int_D {q\,\;{\textbf{k}}\cdot \frac{1} {e_3} \nabla \times \left( {e_3 \, q \;{\textbf{k}}\times {\textbf{U}}_h } \right)\;dv} \\
  %
  \equiv& \sum\limits_{i,j,k}
  {q} \    \biggl\{ \;\;
  \delta_{i+1/2} \left[   -\, {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; U^{i+1/2}_{j}}    \right]
  - \delta_{j+1/2} \left[       {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; V^{i}_{j+1/2}}    \right]
  \;\;\biggr\}        &&  \\
  %
  \equiv& \sum\limits_{i,j,k}
  \biggl\{   \delta_i [q] \  {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; U^{i+1/2}_{j}}
  + \delta_j [q] \  {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}  \; V^{i}_{j+1/2}}   \biggr\}
  && \\
  %
  ... & &&\\
  &Demonstation \ to \ be \ done... &&\\
  ... & &&\\
  %
  \equiv& \frac{1} {2} \sum\limits_{i,j,k}
  \biggl\{	\delta_i    \Bigl[    \left(  {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2   \Bigr]\;
  \overline{\overline {U}}^{\,i,j+1/2}
  + \delta_j 	\Bigl[    \left( {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2     \Bigr]\;
  \overline{\overline {V}}^{\,i+1/2,j}
  \biggr\}
  &&  \\
  %
  \equiv& - \frac{1} {2} \sum\limits_{i,j,k} 	\left( {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2\;
  \biggl\{    \delta_{i+1/2}
  \left[   \overline{\overline {U}}^{\,i,j+1/2}    \right]
  + \delta_{j+1/2}
  \left[   \overline{\overline {V}}^{\,i+1/2,j}     \right]
  \biggr\}    && \\
  %
  \equiv& \sum\limits_{i,j,k} - \frac{1} {2} \left( {{^i_j}\mathbb{Q}^{+1/2}_{+1/2}} \right)^2
  \; \overline{\overline{ b_t^{}\, \chi}}^{\,i+1/2,\,j+1/2}  &&\\
  %
  \ \ \equiv& \ 0     &&\\
\end{flalign*}

%% =================================================================================================
\section{Conservation properties on tracers}
\label{sec:INVARIANTS_5}

All the numerical schemes used in \NEMO\ are written such that the tracer content is conserved by
the internal dynamics and physics (equations in flux form).
For advection,
only the CEN2 scheme (\ie\ $2^{nd}$ order finite different scheme) conserves the global variance of tracer.
Nevertheless the other schemes ensure that the global variance decreases
(\ie\ they are at least slightly diffusive).