Skip to content
Snippets Groups Projects
chap_TRA.tex 85.7 KiB
Newer Older
\documentclass[../main/NEMO_manual]{subfiles}

\begin{document}

\chapter{Ocean Tracers (TRA)}
\label{chap:TRA}

\chaptertoc

\paragraph{Changes record} ~\\

{\footnotesize
  \begin{tabularx}{\textwidth}{l||X|X}
    Release          & Author(s)                                   & Modifications       \\
    \hline
    {\em        4.0} & {\em Christian \'{E}th\'{e}               } & {\em Review       } \\
    {\em        3.6} & {\em Gurvan Madec                         } & {\em Update       } \\
    {\em $\leq$ 3.4} & {\em Gurvan Madec and S\'{e}bastien Masson} & {\em First version} \\
  \end{tabularx}
}

\clearpage

% missing/update
% traqsr: need to coordinate with SBC module

%STEVEN :  is the use of the word "positive" to describe a scheme enough, or should it be "positive definite"?
%I added a comment to this effect on some instances of this below

Using the representation described in \autoref{chap:DOM}, several semi -discrete space forms of
the tracer equations are available depending on the vertical coordinate used and on the physics used.
In all the equations presented here, the masking has been omitted for simplicity.
One must be aware that all the quantities are masked fields and that
each time a mean or difference operator is used, the resulting field is multiplied by a mask.

The two active tracers are potential temperature and salinity.
Their prognostic equations can be summarized as follows:
\[
  \text{NXT} =     \text{ADV} + \text{LDF} + \text{ZDF} + \text{SBC}
               + \{\text{QSR},  \text{BBC},  \text{BBL},  \text{DMP}, \text{ISF}\}
\]

NXT stands for next, referring to the time-stepping.
From left to right, the terms on the rhs of the tracer equations are the advection (ADV),
the lateral diffusion (LDF), the vertical diffusion (ZDF),
the contributions from the external forcings (SBC: Surface Boundary Condition,
QSR: penetrative Solar Radiation, and BBC: Bottom Boundary Condition),
the contribution from the bottom boundary Layer (BBL) parametrisation, an internal damping (DMP) and
the contribution from the floating ice shelves (ISF) term.
The terms QSR, BBC, BBL, DMP and ISF are optional.
The external forcings and parameterisations require complex inputs and complex calculations
(\eg\ bulk formulae, estimation of mixing coefficients) that are carried out in the SBC,
LDF, ZDF and ISF modules and described in \autoref{chap:SBC}, \autoref{chap:LDF},
\autoref{chap:ZDF} and \autoref{chap:LIO}, respectively.
Note that \mdl{tranpc}, the non-penetrative convection module, 
is located in the \path{./src/OCE/TRA} directory because it directly modifies the tracer fields. 
However, it is described alongside the model's vertical physics (ZDF), together with other available 
parameterizations of convection. Similarly, \mdl{tramle}, which implements the mixed-layer eddy parameterization, 
and \mdl{traisf}, which handles ice-shelf fluxes, are also included in the \path{./src/OCE/TRA} directory 
but are addressed in their respective contexts respectively (LDF) and (LIO).

In the present chapter we also describe the diagnostic equations used to
compute the sea-water properties (density, Brunt-V\"{a}is\"{a}l\"{a} frequency, specific heat and
freezing point with associated modules \mdl{eosbn2} and \mdl{phycst}).

The different options available to the user are managed by namelist logicals.
For each equation term \textit{TTT}, the namelist logicals are \textit{ln\_traTTT\_xxx},
where \textit{xxx} is a 3 or 4 letter acronym corresponding to each optional scheme.
The equivalent code can be found in the \textit{traTTT} or \textit{traTTT\_xxx} module,
in the \path{./src/OCE/TRA} directory.

The user has the option of extracting each tendency term on the RHS of the tracer equation for output
(\np{ln_tra_trd}{ln\_tra\_trd} or \np[=.true.]{ln_tra_mxl}{ln\_tra\_mxl}),
as described in \autoref{chap:DIA}.

%% =================================================================================================
\section[Tracer advection (\textit{traadv.F90})]{Tracer advection (\protect\mdl{traadv})}
\label{sec:TRA_adv}

\begin{listing}
  \nlst{namtra_adv}
  \caption{\forcode{&namtra_adv}}
  \label{lst:namtra_adv}
\end{listing}

When considered (\ie\ when \np{ln_traadv_OFF}{ln\_traadv\_OFF} is not set to \forcode{.true.}),
the advection tendency of a tracer is expressed in flux form,
\ie\ as the divergence of the advective fluxes.
Its discrete expression is given by:
\begin{equation}
  \label{eq:TRA_adv}
  ADV_\tau = - \frac{1}{b_t} \Big(   \delta_i [ e_{2u} \, e_{3u} \; u \; \tau_u]
                                   + \delta_j [ e_{1v} \, e_{3v} \; v \; \tau_v] \Big)
             - \frac{1}{e_{3t}} \delta_k [w \; \tau_w]
\end{equation}
where $\tau$ is either T or S, and $b_t = e_{1t} \, e_{2t} \, e_{3t}$ is the volume of $T$-cells.
The flux form in \autoref{eq:TRA_adv} implicitly requires the use of the continuity equation.
Indeed, it is obtained by using the following equality:
$\nabla \cdot (\vect U \, T) = \vect U \cdot \nabla T$ which
results from the use of the continuity equation,
$\partial_t e_3 + e_3 \; \nabla \cdot \vect U = 0$
(which reduces to $\nabla \cdot \vect U = 0$ in linear free surface,
\ie\ \key{linssh} specified instead of \key{qco}).
Therefore it is of paramount importance to
design the discrete analogue of the advection tendency so that
it is consistent with the continuity equation in order to
enforce the conservation properties of the continuous equations.
In other words, by setting $\tau = 1$ in (\autoref{eq:TRA_adv}) we recover
the discrete form of the continuity equation which is used to calculate the vertical velocity.
\begin{figure}
  \centering
  \includegraphics[width=0.66\textwidth]{TRA_adv_scheme}
  \caption[Ways to evaluate the tracer value and the amount of tracer exchanged]{
    Schematic representation of some ways used to evaluate the tracer value at $u$-point and
    the amount of tracer exchanged between two neighbouring grid points.
    Upsteam biased scheme (ups):
    the upstream value is used and the black area is exchanged.
    Piecewise parabolic method (ppm):
    a parabolic interpolation is used and the black and dark grey areas are exchanged.
    Monotonic upstream scheme for conservative laws (muscl):
    a parabolic interpolation is used and black, dark grey and grey areas are exchanged.
    Second order scheme (cen2):
    the mean value is used and black, dark grey, grey and light grey areas are exchanged.
    Note that this illustration does not include the flux limiter used in ppm and muscl schemes.}
  \label{fig:TRA_adv_scheme}
\end{figure}

The key difference between the advection schemes available in \NEMO\ is the choice made in
space and time interpolation to define the value of the tracer at the velocity points
(\autoref{fig:TRA_adv_scheme}).

Along solid lateral and bottom boundaries a zero tracer flux is automatically specified,
since the normal velocity is zero there.
At the sea surface the boundary condition depends on the type of sea surface chosen:

\begin{description}
\item [linear free surface] (\key{linssh} specified)
  the first level thickness is constant in time:
  the vertical boundary condition is applied at the fixed surface $z = 0$ rather than
  on the moving surface $z = \eta$.
  There is a non-zero advective flux which is set for
  all advection schemes as $\tau_w|_{k = 1/2} = T_{k = 1}$,
  \ie\ the product of surface velocity (at $z = 0$) by the first level tracer value.
\item [non-linear free surface] (\key{qco} specified)
  convergence/divergence in the first ocean level moves the free surface up/down.
  There is no tracer advection through it so that
  the advective fluxes through the surface are also zero.
\end{description}

In all cases, this boundary condition retains local conservation of tracer.
Global conservation is obtained in non-linear free surface case,
but \textit{not} in the linear free surface case.
Nevertheless, in the latter case,
it is achieved to a good approximation since the non-conservative term is
the product of the time derivative of the tracer and the free surface height,
two quantities that are not correlated
\citep{roullet.madec_JGR00, griffies.pacanowski.ea_MWR01, campin.adcroft.ea_OM04}.

The velocity field that appears in (\autoref{eq:TRA_adv} is
the centred (\textit{now}) \textit{effective} ocean velocity, \ie\ the \textit{eulerian} velocity
(see \autoref{chap:DYN}) plus the eddy induced velocity (\textit{eiv}) and/or
the mixed layer eddy induced velocity (\textit{eiv}) when those parameterisations are used
(see \autoref{chap:LDF}).

Several tracer advection scheme are proposed,
namely a $2^{nd}$ or $4^{th}$ order \textbf{CEN}tred schemes (CEN),
a $2^{nd}$ or $4^{th}$ order \textbf{F}lux \textbf{C}orrected \textbf{T}ransport scheme (FCT),
a \textbf{M}onotone \textbf{U}pstream \textbf{S}cheme for
\textbf{C}onservative \textbf{L}aws scheme (MUSCL),
a $3^{rd}$ \textbf{U}pstream \textbf{B}iased \textbf{S}cheme (UBS, also often called UP3),
and a \textbf{Q}uadratic \textbf{U}pstream \textbf{I}nterpolation for
\textbf{C}onvective \textbf{K}inematics with
\textbf{E}stimated \textbf{S}treaming \textbf{T}erms scheme (QUICKEST).
The choice is made in the \nam{tra_adv}{tra\_adv} namelist,
by setting to \forcode{.true.} one of the logicals \textit{ln\_traadv\_xxx}.
The corresponding code can be found in the \textit{traadv\_xxx.F90} module,
where \textit{xxx} is a 3 or 4 letter acronym corresponding to each scheme.
By default (\ie\ in the reference namelist, \textit{namelist\_ref}),
all the logicals are set to \forcode{.false.}.
If the user does not select an advection scheme in the configuration namelist
(\textit{namelist\_cfg}), the tracers will \textit{not} be advected!

Details of the advection schemes are given below.
The choosing an advection scheme is a complex matter which depends on the
model physics, model resolution, type of tracer, as well as the issue of numerical cost.
In particular, we note that

\begin{enumerate}
\item CEN and FCT schemes require an explicit diffusion operator while
  the other schemes are diffusive enough so that they do not necessarily need additional diffusion;
\item CEN and UBS are not \textit{positive} schemes \footnote{negative values can appear in
    an initially strictly positive tracer field which is advected},
  implying that false extrema are permitted.
  Their use is not recommended on passive tracers;
\item It is recommended that the same advection-diffusion scheme is used on
  both active and passive tracers.
\end{enumerate}

Indeed, if a source or sink of a passive tracer depends on an active one,
the difference of treatment of active and passive tracers can create
very nice-looking frontal structures that are pure numerical artefacts.
Nevertheless, most of our users set a different treatment on passive and active tracers,
that's the reason why this possibility is offered.
We strongly suggest them to perform a sensitivity experiment using a same treatment to
assess the robustness of their results.

%% =================================================================================================
\subsection[CEN: Centred scheme (\forcode{ln_traadv_cen})]{CEN: Centred scheme (\protect\np{ln_traadv_cen}{ln\_traadv\_cen})}
\label{subsec:TRA_adv_cen}

%        2nd order centred scheme

The \textbf{CEN}tred advection scheme (CEN) is used when \np[=.true.]{ln_traadv_cen}{ln\_traadv\_cen}.
Its order ($2^{nd}$ or $4^{th}$) can be chosen independently on
horizontal (iso-level) and vertical direction by
setting \np{nn_cen_h}{nn\_cen\_h} and \np{nn_cen_v}{nn\_cen\_v} to $2$ or $4$.
CEN implementation can be found in the \mdl{traadv\_cen} module.

In the $2^{nd}$ order centred formulation (CEN2), the tracer at velocity points is evaluated as
the mean of the two neighbouring $T$-point values.
For example, in the $i$-direction :
\begin{equation}
  \label{eq:TRA_adv_cen2}
  \tau_u^{cen2} = \overline T ^{i + 1/2}
\end{equation}

CEN2 is non diffusive (\ie\ it conserves the tracer variance, $\tau^2$) but
dispersive (\ie\ it may create false extrema).
It is therefore notoriously noisy and must be used in conjunction with
an explicit diffusion operator to produce a sensible solution.
When the model is time-stepped using
a leapfrog scheme in conjunction with an Asselin time-filter,
$T$ in (\autoref{eq:TRA_adv_cen2}) is the \textit{now} tracer value.
In contrast, when the model employs an RK3 scheme, 
$T$ in (\autoref{eq:TRA_adv_cen2}) refers to the \textit{before} tracer value 
during the first stage,and the \textit{now} tracer value during the second and third stages.

Note that using the CEN2, the overall tracer advection is of second order accuracy since
both (\autoref{eq:TRA_adv}) and (\autoref{eq:TRA_adv_cen2}) have this order of accuracy.

%        4nd order centred scheme

In the $4^{th}$ order formulation (CEN4),
tracer values are evaluated at u- and v-points as a $4^{th}$ order interpolation,
and thus depend on the four neighbouring $T$-points.
For example, in the $i$-direction:
\begin{equation}
  \label{eq:TRA_adv_cen4}
  \tau_u^{cen4} = \overline{T - \frac{1}{6} \, \delta_i \Big[ \delta_{i + 1/2}[T] \, \Big]}^{\,i + 1/2}
\end{equation}
In the vertical direction (\np[=4]{nn_cen_v}{nn\_cen\_v}),
a $4^{th}$ COMPACT interpolation has been prefered \citep{demange_phd14}.
In the COMPACT scheme, both the field and its derivative are interpolated,
which leads, after a matrix inversion, spectral characteristics similar to schemes of higher order
\citep{lele_JCP92}.

Strictly speaking, the CEN4 scheme is not a $4^{th}$ order advection scheme but
a $4^{th}$ order evaluation of advective fluxes,
since the divergence of advective fluxes \autoref{eq:TRA_adv} is kept at $2^{nd}$ order.
The expression \textit{$4^{th}$ order scheme} used in oceanographic literature is
usually associated with the scheme presented here.
Introducing a ``true'' $4^{th}$ order advection scheme is feasible but, for consistency reasons,
it requires changes in the discretisation of the tracer advection together with
changes in the continuity equation, and the momentum advection and pressure terms.

A direct consequence of the pseudo-fourth order nature of the scheme is that it is not non-diffusive,
\ie\ the global variance of a tracer is not preserved using CEN4.
Furthermore, it must be used in conjunction with an explicit diffusion operator to
produce a sensible solution.
As in CEN2 case, when the model is time-stepped using
a leapfrog scheme in conjunction with an Asselin time-filter,
$T$ in (\autoref{eq:TRA_adv_cen4}) is the \textit{now} tracer value.
In contrast, when the model employs an RK3 scheme, 
$T$ in (\autoref{eq:TRA_adv_cen4}) refers to the \textit{before} tracer value 
during the first stage,and the \textit{now} tracer value during the second and third stages.

At a $T$-grid cell adjacent to a boundary (coastline, bottom and surface),
an additional hypothesis must be made to evaluate $\tau_u^{cen4}$.
This hypothesis usually reduces the order of the scheme.
Here we choose to set the gradient of $T$ across the boundary to zero.
Alternative conditions can be specified,
such as a reduction to a second order scheme for these near boundary grid points.

%% =================================================================================================
\subsection[FCT: Flux Corrected Transport scheme (\forcode{ln_traadv_fct})]{FCT: Flux Corrected Transport scheme (\protect\np{ln_traadv_fct}{ln\_traadv\_fct})}
\label{subsec:TRA_adv_tvd}

The \textbf{F}lux \textbf{C}orrected \textbf{T}ransport schemes (FCT) is used when
\np[=.true.]{ln_traadv_fct}{ln\_traadv\_fct}.
Its order ($2^{nd}$ or $4^{th}$) can be chosen independently on
horizontal (iso-level) and vertical direction by
setting \np{nn_fct_h}{nn\_fct\_h} and \np{nn_fct_v}{nn\_fct\_v} to $2$ or $4$.
FCT implementation can be found in the \mdl{traadv\_fct} module.

In FCT formulation, the tracer at velocity points is evaluated using
a combination of an upstream (UP1) and a centred scheme.
For example, in the $i$-direction :
\begin{equation}
  \label{eq:TRA_adv_fct}
  \begin{split}
    \tau_u^{up1} &=
    \begin{cases}
                     T_{i + 1} & \text{if~} u_{i + 1/2} <    0 \\
                     T_i       & \text{if~} u_{i + 1/2} \geq 0 \\
    \end{cases} \\
    \tau_u^{fct} &= \tau_u^{up1} + c_u \, \big( \tau_u^{cen} - \tau_u^{up1} \big)
  \end{split}
\end{equation}
where $c_u$ is a flux limiter function taking values between 0 and 1.
The FCT order is the one of the centred scheme used
(\ie\ it depends on the setting of \np{nn_fct_h}{nn\_fct\_h} and \np{nn_fct_v}{nn\_fct\_v}).
There exist many ways to define $c_u$, each corresponding to a different FCT scheme.
The one chosen in \NEMO\ is described in \citet{zalesak_JCP79}.
$c_u$ only departs from $1$ when the advective term produces a local extremum in the tracer field.
The resulting scheme is quite expensive but \textit{positive}.
It can be used on both active and passive tracers.
A comparison of FCT-2 with MUSCL and a MPDATA scheme can be found in \citet{levy.estublier.ea_GRL01}.

For stability reasons (see \autoref{chap:TD}),
$\tau_u^{cen}$ is evaluated in (\autoref{eq:TRA_adv_fct}) using the \textit{now} tracer while
$\tau_u^{up1}$ is evaluated using the \textit{before} tracer.

The FCT procedure is among the most computationally intensive components of the code. 
Under RK3 time-stepping, it typically runs three times per cycle. 
A practical optimization is to use a CEN algorithm to estimate tracer advective terms 
during stages 1 and 2, reserving the full FCT procedure for stage 3.

The FCT involves integrating low-order advection and fluxes, which are then used to compute 
corrective fluxes. These are obtained by subtracting low-order fluxes from high-order fluxes 
and applying the nonoscillatory limiter routine. The resulting corrective flux divergence is 
added to the right-hand side. To mitigate instabilities caused by low-order integration, 
sub-stepping is applied.

Local implicit vertical advection (\np[=.true.]{ln_zad_Aimp}{ln\_zad\_Aimp}) is required 
within the FCT scheme due to the low-order integration. 
The process is optimized when \np[=1]{nn_fct_imp}{nn\_fct\_imp} and less efficient when 
\np[=2]{nn_fct_imp}{nn\_fct\_imp}.

%% =================================================================================================
\subsection[MUSCL: Monotone Upstream Scheme for Conservative Laws (\forcode{ln_traadv_mus})]{MUSCL: Monotone Upstream Scheme for Conservative Laws (\protect\np{ln_traadv_mus}{ln\_traadv\_mus})}
\label{subsec:TRA_adv_mus}

The \textbf{M}onotone \textbf{U}pstream \textbf{S}cheme for \textbf{C}onservative \textbf{L}aws
(MUSCL) is used when \np[=.true.]{ln_traadv_mus}{ln\_traadv\_mus}.
MUSCL implementation can be found in the \mdl{traadv\_mus} module.

MUSCL has been first implemented in \NEMO\ by \citet{levy.estublier.ea_GRL01}.
In its formulation, the tracer at velocity points is evaluated assuming
a linear tracer variation between two $T$-points (\autoref{fig:TRA_adv_scheme}).
For example, in the $i$-direction :
\[
  % \label{eq:TRA_adv_mus}
  \tau_u^{mus} = \lt\{
  \begin{split}
    \tau_i        &+ \frac{1}{2} \lt( 1 - \frac{u_{i + 1/2} \, \rdt}{e_{1u}} \rt)
    \widetilde{\partial_i        \tau} & \text{if~} u_{i + 1/2} \geqslant 0 \\
    \tau_{i + 1/2} &+ \frac{1}{2} \lt( 1 + \frac{u_{i + 1/2} \, \rdt}{e_{1u}} \rt)
    \widetilde{\partial_{i + 1/2} \tau} & \text{if~} u_{i + 1/2} <         0
  \end{split}
                                                                                                      \rt.
\]
where $\widetilde{\partial_i \tau}$ is the slope of the tracer on which
a limitation is imposed to ensure the \textit{positive} character of the scheme.

The time stepping is performed using a forward scheme,
that is the \textit{before} tracer field is used to evaluate $\tau_u^{mus}$.

For an ocean grid point adjacent to land and where the ocean velocity is directed toward land,
an upstream flux is used.
This choice ensure the \textit{positive} character of the scheme.
In addition, fluxes round a grid-point where a runoff is applied can optionally be computed using
upstream fluxes (\np[=.true.]{ln_mus_ups}{ln\_mus\_ups}).

%% =================================================================================================
\subsection[UBS a.k.a. UP3: Upstream-Biased Scheme (\forcode{ln_traadv_ubs})]{UBS a.k.a. UP3: Upstream-Biased Scheme (\protect\np{ln_traadv_ubs}{ln\_traadv\_ubs})}
\label{subsec:TRA_adv_ubs}

The \textbf{U}pstream-\textbf{B}iased \textbf{S}cheme (UBS) is used when
\np[=.true.]{ln_traadv_ubs}{ln\_traadv\_ubs}.
UBS implementation can be found in the \mdl{traadv\_ubs} module.

The UBS scheme, often called UP3, is also known as the Cell Averaged QUICK scheme
(\textbf{Q}uadratic \textbf{U}pstream \textbf{I}nterpolation for
\textbf{C}onvective \textbf{K}inematics).
It is an upstream-biased third order scheme based on an upstream-biased parabolic interpolation.
For example, in the $i$-direction:
\begin{equation}
  \label{eq:TRA_adv_ubs}
  \tau_u^{ubs} = \overline T ^{i + 1/2} - \frac{1}{6}
    \begin{cases}
      \tau"_i       & \text{if~} u_{i + 1/2} \geqslant 0 \\
      \tau"_{i + 1} & \text{if~} u_{i + 1/2} <         0
    \end{cases}
  \quad \text{where~} \tau"_i = \delta_i \lt[ \delta_{i + 1/2} [\tau] \rt]
\end{equation}

This results in a dissipatively dominant (i.e. hyper-diffusive) truncation error
\citep{shchepetkin.mcwilliams_OM05}.
The overall performance of the advection scheme is similar to that reported in
\cite{farrow.stevens_JPO95}.
It is a relatively good compromise between accuracy and smoothness.
Nevertheless the scheme is not \textit{positive}, meaning that false extrema are permitted,
but the amplitude of such are significantly reduced over the centred second or fourth order method.
Therefore it is not recommended that it should be applied to
a passive tracer that requires positivity.

The intrinsic diffusion of UBS makes its use risky in the vertical direction where
the control of artificial diapycnal fluxes is of paramount importance
\citep{shchepetkin.mcwilliams_OM05, demange_phd14}.
Therefore the vertical flux is evaluated using either a $2^nd$ order FCT scheme or
a $4^th$ order COMPACT scheme (\np[=2 or 4]{nn_ubs_v}{nn\_ubs\_v}).

For stability reasons (see \autoref{chap:TD}),
the first term  in \autoref{eq:TRA_adv_ubs} (which corresponds to a second order centred scheme)
is evaluated using the \textit{now}    tracer (centred in time) while
the second term (which is the diffusive part of the scheme),
is evaluated using the \textit{before} tracer (forward in time).
This choice is discussed by \citet{webb.de-cuevas.ea_JAOT98} in
the context of the QUICK advection scheme.
UBS and QUICK schemes only differ by one coefficient.
Replacing 1/6 with 1/8 in \autoref{eq:TRA_adv_ubs} leads to the QUICK advection scheme
\citep{webb.de-cuevas.ea_JAOT98}.
This option is not available through a namelist parameter, since the 1/6 coefficient is hard coded.
Nevertheless it is quite easy to make the substitution in the \mdl{traadv\_ubs} module and
obtain a QUICK scheme.

Note that it is straightforward to rewrite \autoref{eq:TRA_adv_ubs} as follows:
\begin{gather}
  \label{eq:TRA_adv_ubs2}
  \tau_u^{ubs} = \tau_u^{cen4} + \frac{1}{12}
    \begin{cases}
      + \tau"_i       & \text{if} \ u_{i + 1/2} \geqslant 0 \\
      - \tau"_{i + 1} & \text{if} \ u_{i + 1/2} <         0
    \end{cases}
  \intertext{or equivalently}
  % \label{eq:TRA_adv_ubs2b}
  u_{i + 1/2} \ \tau_u^{ubs} = u_{i + 1/2} \, \overline{T - \frac{1}{6} \, \delta_i \Big[ \delta_{i + 1/2}[T] \Big]}^{\,i + 1/2}
                             - \frac{1}{2} |u|_{i + 1/2} \, \frac{1}{6} \, \delta_{i + 1/2} [\tau"_i] \nonumber
\end{gather}

\autoref{eq:TRA_adv_ubs2} has several advantages.
Firstly, it clearly reveals that the UBS scheme is based on the fourth order scheme to which
an upstream-biased diffusion term is added.
Secondly,
this emphasises that the $4^{th}$ order part (as well as the $2^{nd}$ order part as stated above) has to be evaluated at the \textit{now} time step using \autoref{eq:TRA_adv_ubs}.
Thirdly, the diffusion term is in fact a biharmonic operator with
an eddy coefficient which is simply proportional to the velocity:
$A_u^{lm} = \frac{1}{12} \, {e_{1u}}^3 \, |u|$.
Note the current version of \NEMO\ uses the computationally more efficient formulation
\autoref{eq:TRA_adv_ubs}.

%% =================================================================================================
\subsection[QCK: QuiCKest scheme (\forcode{ln_traadv_qck})]{QCK: QuiCKest scheme (\protect\np{ln_traadv_qck}{ln\_traadv\_qck})}
\label{subsec:TRA_adv_qck}

The \textbf{Q}uadratic \textbf{U}pstream \textbf{I}nterpolation for
\textbf{C}onvective \textbf{K}inematics with \textbf{E}stimated \textbf{S}treaming \textbf{T}erms
(QUICKEST) scheme proposed by \citet{leonard_CMAME79} is used when
\np[=.true.]{ln_traadv_qck}{ln\_traadv\_qck}.
QUICKEST implementation can be found in the \mdl{traadv\_qck} module.

QUICKEST is the third order Godunov scheme which is associated with the ULTIMATE QUICKEST limiter
\citep{leonard_CMAME91}.
It has been implemented in \NEMO\ by G. Reffray (Mercator Ocean) and
can be found in the \mdl{traadv\_qck} module.
The resulting scheme is quite expensive but \textit{positive}.
It can be used on both active and passive tracers.
However, the intrinsic diffusion of QCK makes its use risky in the vertical direction where
the control of artificial diapycnal fluxes is of paramount importance.
Therefore the vertical flux is evaluated using the CEN2 scheme.
This no longer guarantees the positivity of the scheme.
The use of FCT in the vertical direction (as for the UBS case) should be implemented to
restore this property.

\cmtgm{Cross term are missing in the current implementation....}

%% =================================================================================================
\section[Tracer lateral diffusion (\textit{traldf.F90})]{Tracer lateral diffusion (\protect\mdl{traldf})}
\label{sec:TRA_ldf}

\begin{listing}
  \nlst{namtra_ldf}
  \caption{\forcode{&namtra_ldf}}
  \label{lst:namtra_ldf}
\end{listing}

The lateral diffusion operator for tracers models the physical process of horizontal mixing. 
NEMO provides multiple options that can be combined to construct a lateral diffusion operator 
suited to the advection scheme, resolution, and coordinate system of the experiment. 
These options are defined in the \nam{tra_ldf}{tra\_ldf} namelist variables. 
Choices for specifying the lateral diffusion operator includes :
(i) the operator type and scale which specifies the form of the operator and thus the spatial 
scale at which it acts, 
(ii) the direction of action which defines the orientation of the operator. 
For rotated operators, additional options must be specified, 
slope is computed in the \mdl{ldfslp} module (see \autoref{chap:LDF})
(iii) the eddy diffusivity structure, which control the temporal and 
spatial distribution of eddy diffusivity (see \autoref{chap:LDF}). 
These combinations allow users to construct a diffusion operator that aligns 
with the specific requirements of their experiment.

The lateral diffusion of tracers is evaluated using a forward scheme,
\ie\ the tracers appearing in its expression are the \textit{before} tracers in time. 
It is not true in case ot a rorated operator. In this case a vertical component that appears, 
it is solved implicitly together with the vertical diffusion term 
When \np[=.true.]{ln_traldf_msc}{ln\_traldf\_msc}, 
a Method of Stabilizing Correction is used in which the pure vertical component is split into 
an explicit and an implicit part \citep{lemarie.debreu.ea_OM12}.

%% =================================================================================================
\subsection[Type of operator (\forcode{ln_traldf_}\{\forcode{OFF,lap,blp}\})]{Type of operator (\protect\np{ln_traldf_OFF}{ln\_traldf\_OFF}, \protect\np{ln_traldf_lap}{ln\_traldf\_lap}, or \protect\np{ln_traldf_blp}{ln\_traldf\_blp})}
\label{subsec:TRA_ldf_op}

Three operator options are proposed and, one and only one of them must be selected:

\begin{description}
\item [{\np[=.true.]{ln_traldf_OFF}{ln\_traldf\_OFF}}] no operator selected,
  the lateral diffusive tendency will not be applied to the tracer equation.
  This option can be used when the selected advection scheme is diffusive enough
  (MUSCL scheme for example).
\item [{\np[=.true.]{ln_traldf_lap}{ln\_traldf\_lap}}] a laplacian operator is selected.
  This harmonic operator takes the following expression:
  $\mathcal{L}(T) = \nabla \cdot A_{ht} \; \nabla T $,
  where the gradient operates along the selected direction (see \autoref{subsec:TRA_ldf_dir}),
  and $A_{ht}$ is the eddy diffusivity coefficient expressed in $m^2/s$ (see \autoref{chap:LDF}).
\item [{\np[=.true.]{ln_traldf_blp}{ln\_traldf\_blp}}] a bilaplacian operator is selected.
  This biharmonic operator takes the following expression:
  $\mathcal{B} = - \mathcal{L}(\mathcal{L}(T)) = - \nabla \cdot b \nabla (\nabla \cdot b \nabla T)$
  where the gradient operats along the selected direction,
  and $b^2 = B_{ht}$ is the eddy diffusivity coefficient expressed in $m^4/s$
  (see \autoref{chap:LDF}).
  In the code, the bilaplacian operator is obtained by calling the laplacian twice.
\end{description}

Both laplacian and bilaplacian operators ensure the total tracer variance decrease.
Their primary role is to provide strong dissipation at the smallest scale supported by the grid while
minimizing the impact on the larger scale features.
The main difference between the two operators is the scale selectiveness.
The bilaplacian damping time (\ie\ its spin down time) scales like
$\lambda^{-4}$ for disturbances of wavelength $\lambda$
(so that short waves damped more rapidelly than long ones),
whereas the laplacian damping time scales only like $\lambda^{-2}$.

%% =================================================================================================
\subsection[Action direction (\forcode{ln_traldf_}\{\forcode{lev,hor,iso,triad}\})]{Direction of action (\protect\np{ln_traldf_lev}{ln\_traldf\_lev}, \protect\np{ln_traldf_hor}{ln\_traldf\_hor}, \protect\np{ln_traldf_iso}{ln\_traldf\_iso}, or \protect\np{ln_traldf_triad}{ln\_traldf\_triad})}
\label{subsec:TRA_ldf_dir}

\NEMO\ provides three primary approaches for simulating diffusion, 
each influencing whether a rotation needs to be applied to the diffusion operator.
(see \autoref{fig:TRA_ldf_dir})
\begin{description}
\item [{\np[=.true.]{ln_traldf_lev}{ln\_traldf\_lev}}] : 
  the direction of action aligns with the vertical coordinate level and 
  there is no need for any rotation of the operator 
  (this is not recommended in \textit{s}-coordinate).
\item [{\np[=.true.]{ln_traldf_hor}{ln\_traldf\_hor}}] : 
  horizontal levels apprximates geopotential levels. 
  They do not necessarly align along the vertical coordinate levels. 
  In \textit{z}-coordinate (\np[=.true.]{ln_zco}{ln\_zco}) horizontal levels 
  align with z-levels. So no rotation is needed. 
  In \textit{s}-coordinate (\np[=.true.]{ln_sco}{ln\_sco}) horizontal levels 
  do not align with s-levels. 
  Therefore a rotation of the diffusion operator is required.
\item [{\np[=.true.]{ln_traldf_iso}{ln\_traldf\_iso}} or {\np[=.true.]{ln_traldf_triad}{ln\_traldf\_triad}} ] : 
  diffusion follows isoneutral layers, which are often sloped relative to both 
  horizontal and models levels. 
  In this case the diffusion operator is always rotated.
\end{description}

The discrete forms of these operators are presented in the following two subsections. 
They include one iso-level operator (\mdl{traldf\_lev}), 
which requires no additional rotation beyond the natural one associated with the model levels, 
and two rotated operators (\mdl{traldf\_iso} and \mdl{traldf\_triad}).

\begin{figure}
  \centering
  \includegraphics[width=0.4\textwidth]{TRA_ldf_dir}
  \caption[Combination of direction of action of diffusive operators and of the choice of vertical coordinate]{
    Overview of the tracer diffusive operator selected (rotated (iso, triad) or non-rotated (lev)) based on 
    the vertical coordinate and the direction of action specified}
  \label{fig:TRA_ldf_dir}
\end{figure}

%% =================================================================================================
\subsection[Iso-level (bi-)laplacian operator (\forcode{ln_traldf_iso})]{Iso-level (bi-)laplacian operator ( \protect\np{ln_traldf_iso}{ln\_traldf\_iso})}
\label{subsec:TRA_ldf_lev}

In z-coordinate with or without partial steps (\np[=.true.]{ln_zco}{ln\_zco} 
or \np[=.true.]{ln_zps}{ln\_zps}), the iso-level diffusion operator 
is also a horizontal operator (i.e.acting along geopotential surfaces).
Choices \np[=.true.]{ln_traldf_lev}{ln\_traldf\_lev} 
and \np[=.true.]{ln_traldf_hor}{ln\_traldf\_hor} are thus equivalent. 
While in s-coordinate (\np[=.true.]{ln_sco}{ln\_sco}), 
it is simply an iso-level diffusion operator (\np[=.true.]{ln_traldf_lev}{ln\_traldf\_lev}).
In both cases, it significantly contributes to diapycnal mixing.
It is therefore never recommended, even when using it in the bilaplacian case.

The laplacian diffusion operator acting along the model (\textit{i,j})-surfaces is given by:
\begin{equation}
  \label{eq:TRA_ldf_lap}
  D_t^{lT} = \frac{1}{b_t} \Bigg(   \delta_{i} \lt[ A_u^{lT} \; \frac{e_{2u} \, e_{3u}}{e_{1u}} \; \delta_{i + 1/2} [T] \rt]
                                  + \delta_{j} \lt[ A_v^{lT} \; \frac{e_{1v} \, e_{3v}}{e_{2v}} \; \delta_{j + 1/2} [T] \rt] \Bigg)
\end{equation}
where $b_t = e_{1t} \, e_{2t} \, e_{3t}$  is the volume of $T$-cells and
where zero diffusive fluxes is assumed across solid boundaries,
first (and third in bilaplacian case) horizontal tracer derivative are masked.
The iso-level laplacian operator (\np[=.true.]{ln_traldf_lap}{ln\_traldf\_lap}) 
is implemented in the \rou{tra\_ldf\_lap} subroutine found in the \mdl{traldf\_lev} module.
The module also contains \rou{tra\_ldf\_blp}, 
to compute the iso-level bilaplacian operator (\np[=.true.]{ln_traldf_blp}{ln\_traldf\_blp}).

Note that in the partial step $z$-coordinate (\np[=.true.]{ln_zps}{ln\_zps}),
tracers in horizontally adjacent cells are located at different depths in the vicinity of the bottom.

%% =================================================================================================
\subsection{Standard and triad (bi-)laplacian operator}
\label{subsec:TRA_ldf_iso_triad}

%% =================================================================================================
\subsubsection[Standard rotated (bi-)laplacian operator (\textit{traldf\_iso.F90})]{Standard rotated (bi-)laplacian operator (\protect\mdl{traldf\_iso})}
\label{subsec:TRA_ldf_iso}

This operator is used when \np[=.true.]{ln_traldf_iso}{ln\_traldf\_iso}, 
regardless of the chosen vertical coordinate, to ensure that diffusion is oriented 
along isoneutral surfaces.
In s-coordinates (\np[=.true.]{ln_sco}{ln\_sco}), it is also applied when 
a horizontal diffusion direction is specified (\np[=.true.]{ln_traldf_hor}{ln\_traldf\_hor}).

The general form of the second order lateral tracer subgrid scale physics (\autoref{eq:MB_zdf})
takes the following semi-discrete space form in $z$- and $s$-coordinates:
\begin{equation}
  \label{eq:TRA_ldf_iso}
  \begin{split}
    D_T^{lT} = \frac{1}{b_t} \Bigg[ \quad &\delta_i A_u^{lT} \lt( \frac{e_{2u} e_{3u}}{e_{1u}}                      \, \delta_{i + 1/2} [T]
                                                                  - e_{2u} r_{1u} \, \overline{\overline{\delta_{k + 1/2} [T]}}^{\,i + 1/2,k} \rt) \Bigg. \\
                                    +     &\delta_j A_v^{lT} \lt( \frac{e_{1v} e_{3v}}{e_{2v}}                       \, \delta_{j + 1/2} [T]
                                                                  - e_{1v} r_{2v} \, \overline{\overline{\delta_{k + 1/2} [T]}}^{\,j + 1/2,k} \rt)        \\
                                   +     &\delta_k A_w^{lT} \lt( \frac{e_{1w} e_{2w}}{e_{3w}} (r_{1w}^2 + r_{2w}^2) \, \delta_{k + 1/2} [T] \rt.           \\
                                   & \qquad \quad \Bigg. \lt.     - e_{2w} r_{1w} \, \overline{\overline{\delta_{i + 1/2} [T]}}^{\,i,k + 1/2}
                                                                  - e_{1w} r_{2w} \, \overline{\overline{\delta_{j + 1/2} [T]}}^{\,j,k + 1/2} \rt) \Bigg]
  \end{split}
\end{equation}
where $b_t = e_{1t} \, e_{2t} \, e_{3t}$  is the volume of $T$-cells,
$r_1$ and $r_2$ are the slopes between the surface of computation ($z$- or $s$-surfaces) and
the surface along which the diffusion operator acts (\ie\ horizontal or iso-neutral surfaces).
The way these slopes are evaluated is given in \autoref{sec:LDF_slp}.
At the surface, bottom and lateral boundaries,
the turbulent fluxes of heat and salt are set to zero using the mask technique
(see \autoref{sec:LBC_coast}).

The operator in \autoref{eq:TRA_ldf_iso} involves both lateral and vertical derivatives.
For numerical stability, the vertical second derivative must be solved using
the same implicit time scheme as that used in the vertical physics (see \autoref{sec:TRA_zdf}).
For computer efficiency reasons, this term is not computed in the \mdl{traldf\_iso} module,
but in the \mdl{trazdf} module where, if iso-neutral mixing is used,
the vertical mixing coefficient is simply increased by
$\frac{e_{1w} e_{2w}}{e_{3w}}(r_{1w}^2 + r_{2w}^2)$.

This formulation conserves the tracer but does not ensure the decrease of the tracer variance.
Nevertheless the treatment performed on the slopes (see \autoref{chap:LDF}) allows the model to
run safely without any additional background horizontal diffusion \citep{guilyardi.madec.ea_CD01}.

%% =================================================================================================
\subsubsection[Triad rotated (bi-)laplacian operator (\forcode{ln_traldf_triad})]{Triad rotated (bi-)laplacian operator (\protect\np{ln_traldf_triad}{ln\_traldf\_triad})}
\label{subsec:TRA_ldf_triad}

An alternative scheme developed by \cite{griffies.gnanadesikan.ea_JPO98} which
ensures tracer variance decreases is also available in \NEMO\
(\np[=.true.]{ln_traldf_triad}{ln\_traldf\_triad}).
A complete description of the algorithm is given in \autoref{apdx:TRIADS}.

The lateral fourth order bilaplacian operator on tracers is obtained by
applying (\autoref{eq:TRA_ldf_lap}) twice.
The operator requires an additional assumption on boundary conditions:
both first and third derivative terms normal to the coast are set to zero.

The lateral fourth order operator formulation on tracers is obtained by
applying (\autoref{eq:TRA_ldf_iso}) twice.
It requires an additional assumption on boundary conditions:
first and third derivative terms normal to the coast,
normal to the bottom and normal to the surface are set to zero.

%% =================================================================================================
\subsubsection{Option for the rotated operators}
\label{subsec:TRA_ldf_options}

\begin{labeling}{{\np{ln_botmix_triad}{ln\_botmix\_triad}}}
\item [{\np{ln_traldf_msc}{ln\_traldf\_msc}    }] Method of Stabilizing Correction (both operators)
\item [{\np{rn_slpmax}{rn\_slpmax}             }] Slope limit (both operators)
\item [{\np{ln_triad_iso}{ln\_triad\_iso}      }] Pure horizontal mixing in ML (triad only)
\item [{\np{rn_sw_triad}{rn\_sw\_triad}        }] \forcode{=1} switching triad;
  \forcode{= 0} all 4 triads used (triad only)
\item [{\np{ln_botmix_triad}{ln\_botmix\_triad}}] Lateral mixing on bottom (triad only)
\end{labeling}

%% =================================================================================================
\section[Tracer vertical diffusion (\textit{trazdf.F90})]{Tracer vertical diffusion (\protect\mdl{trazdf})}
\label{sec:TRA_zdf}

Options are defined through the \nam{zdf}{zdf} namelist variables.
The formulation of the vertical subgrid scale tracer physics is the same for
all the vertical coordinates, and is based on a laplacian operator.
The vertical diffusion operator given by (\autoref{eq:MB_zdf}) takes
the following semi-discrete space form:
\[
  % \label{eq:TRA_zdf}
  D^{vT}_T = \frac{1}{e_{3t}} \, \delta_k \lt[ \, \frac{A^{vT}_w}{e_{3w}} \delta_{k + 1/2}[T] \, \rt] \quad
  D^{vS}_T = \frac{1}{e_{3t}} \; \delta_k \lt[ \, \frac{A^{vS}_w}{e_{3w}} \delta_{k + 1/2}[S] \, \rt]
\]
where $A_w^{vT}$ and $A_w^{vS}$ are the vertical eddy diffusivity coefficients on
temperature and salinity, respectively.
Generally, $A_w^{vT} = A_w^{vS}$ except when double diffusive mixing is parameterised
(\ie\ \np[=.true.]{ln_zdfddm}{ln\_zdfddm}) or when differential mixing is activated in the parameterization of internal wave-driven mixing (\ie\ \np[=.true.]{ln_tsdiff}{ln\_tsdiff}).
The way these coefficients are evaluated is given in \autoref{chap:ZDF} (ZDF).
Furthermore, when iso-neutral mixing is used,
both mixing coefficients are increased by $\frac{e_{1w} e_{2w}}{e_{3w} }({r_{1w}^2 + r_{2w}^2})$ to
account for the vertical second derivative of \autoref{eq:TRA_ldf_iso}.

At the surface and bottom boundaries, the turbulent fluxes of heat and salt must be specified.
At the surface they are prescribed from the surface forcing and added in a dedicated routine
(see \autoref{subsec:TRA_sbc}), whilst at the bottom they are set to zero for heat and salt unless
a geothermal flux forcing is prescribed as a bottom boundary condition (see \autoref{subsec:TRA_bbc}).

The large eddy coefficient found in the mixed layer together with high vertical resolution implies
that there would be too restrictive constraint on the time step if we use explicit time stepping.
Therefore an implicit time stepping is preferred for the vertical diffusion since
it overcomes the stability constraint.

Because the vertical mixing is always solved implicitly, the update of the tracer fields described in \autoref{eq:TRA_nxt} is done in \mdl{trazdf} module.


%% =================================================================================================
\section{External forcing}
\label{sec:TRA_sbc_qsr_bbc}

Changes in the heat and salt content of the ocean's surface layer result from 
water mass exchanges between the ocean and the atmosphere, land surfaces, icebergs
or sea ice (\mdl{trasbc}). 
Runoff related fluxes are distributed vertically. 
The assimilation module integrates the ocean model with observational data. 
When activated, it is necessary to correct from the concentration and dilution 
effects associated with variations in sea surface height. 
Changes due to water mass exchanges between the ocean and ice-shelves 
are managed in \mdl{traisf}.
Additionally, there is the solar flux, which requires special treatment 
as it penetrates deeper into the ocean, 
necessitating the vertical distribution of the associated heat content (\mdl{traqsr}). 
\NEMO\ can also account for heating caused by geothermal flux (\mdl{trabbl}) 
across the seafloor.

%% =================================================================================================
\subsection[Surface boundary condition (\textit{trasbc.F90})]{Surface boundary condition (\protect\mdl{trasbc})}
\label{subsec:TRA_sbc}

The surface boundary condition for tracers is implemented in a separate module (\mdl{trasbc}) instead of
entering as a boundary condition on the vertical diffusion operator (as in the case of momentum).
This has been found to enhance readability of the code.
The two formulations are completely equivalent;
the forcing terms in trasbc are the surface fluxes divided by the thickness of the top model layer.

Changes in heat content and salt content associated with surface mass fluxes are linked 
to exchanges with the atmosphere (\textit{emp}) and sea ice (freezing, melting, ridging, etc.).
These are exclusively accounted for in the non-solar surface flux ($Q_{ns}$) for heat content 
and in the surface salt flux (\textit{sfx}) for salt content (see \autoref{chap:SBC} for further details).
This help since the forcing formulation is the same for any tracer (including temperature and salinity).
When (\np[=.false.]{ln_traqsr}{ln\_traqsr}), the solar flux is not distributed over the surface 
and is simply added to the non-solar flux.

Changes in heat content and salt content associated with runoff (\textit{rnf}) when \np[=.true.]{ln_rnf}{ln\_rnf} 
are distributed vertically, requiring specific treatment, and are therefore handled separately.

The surface module (\mdl{sbcmod}, see \autoref{chap:SBC}) provides the following forcing fields
(used on tracers):

\begin{labeling}{\textit{rnf}}
\item [$Q_{ns}$] The non-solar part of the net surface heat flux that crosses the sea surface
  (\ie\ the difference between the total surface heat flux and
  the fraction of the short wave flux that penetrates into the water column,
  see \autoref{subsec:TRA_qsr})
  plus the heat content associated with of the mass exchange with the atmosphere and lands.
\item [\textit{sfx}] The salt flux resulting from ice-ocean mass exchange
  (freezing, melting, ridging...)
\item [\textit{emp}] The mass flux exchanged with the atmosphere (evaporation minus precipitation) and
  possibly with the sea-ice and icebergs.
\item [\textit{rnf}] The mass flux associated with runoff
  (see \autoref{sec:SBC_rnf} for further detail of how it acts on temperature and salinity tendencies)
\end{labeling}

\vskip 0.5cm

\noindent In an \textbf{RK3 environment}, the first two stages focus solely on 
estimating advection, Coriolis, and pressure gradient terms. 
The absence of vertical diffusion terms during these initial integrations justifies 
the exclusion of salt and heat forcing. Indeed, it saves two calls of \rou{traqsr}
which is computationally expensive. 
However, for compatibility with the continuity equation, it is necessary to account 
for mass flux forcing (\textit{emp}) at the surface. 
This change of mass at the first level should not impact the salt and temperature, 
so the first level must be corrected from concentration and dilution effects.
\begin{equation}
  \label{eq:TRA_sbc_12}
    F^T_{kstg = 1,2} = - \frac{\textit{emp}}{\rho_o \lt. e_{3t} \rt|_{k = 1}}  \lt. T \rt|_{k = 1} \qquad
    F^S_{kstg = 1,2} = - \frac{\textit{emp}}{\rho_o \lt. e_{3t} \rt|_{k = 1}}  \lt. S \rt|_{k = 1}
\end{equation}

\noindent At the last stage, the surface boundary condition on temperature and salinity is applied as follows:
\begin{equation}
  \label{eq:TRA_sbc_3}
    F^T_{kstg = 3} = \frac{1}{C_p} \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}} Q_{ns}     \qquad
    F^S_{kstg = 3} =               \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}} \textit{sfx}
\end{equation}

\noindent In the linear free surface case (\key{linssh}),
an additional terms correct both temperature and salinity at the third stage only.
On temperature, this term remove the heat content associated with
mass exchange that has been added to $Q_{ns}$.
On salinity, this term mimics the concentration/dilution effect that would have resulted from
a change in the volume of the first level.
As \textit{emp} includes all the mass fluxes, resulting surface boundary condition is applied as follows:
\begin{equation}
  \label{eq:TRA_sbc_lin_3}
    F^T_{kstg = 3} = \frac{1}{C_p} \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}}
          (Q_{ns}       + C_p \, \textit{emp} \lt. T \rt|_{k = 1}) \qquad
    F^S_{kstg = 3} =               \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}}
          (\textit{sfx} +        \textit{emp} \lt. S \rt|_{k = 1})
\end{equation}

Note that an exact conservation of heat and salt content is only achieved with
non-linear free surface.
In the linear free surface case, there is a small imbalance.

\vskip 0.5cm

\noindent In a \textbf{leapfrog environment},
the surface boundary condition on temperature and salinity is applied as follows:
\begin{equation}
  \label{eq:TRA_sbc}
    F^T = \frac{1}{C_p} \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}} \overline{Q_{ns}      }^t \qquad
    F^S =               \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}} \overline{\textit{sfx}}^t
\end{equation}
where $\overline x^t$ means that $x$ is averaged over two consecutive time steps
($t - \rdt / 2$ and $t + \rdt / 2$).
Such time averaging prevents the divergence of odd and even time step (see \autoref{chap:TD}).

In the linear free surface case (\key{linssh}),
an additional term has to be added on both temperature and salinity.
On temperature, this term remove the heat content associated with
mass exchange that has been added to $Q_{ns}$.
On salinity, this term mimics the concentration/dilution effect that would have resulted from
a change in the volume of the first level.
The resulting surface boundary condition is applied as follows:
\begin{equation}
  \label{eq:TRA_sbc_lin}
    F^T = \frac{1}{C_p} \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}}
          \overline{(Q_{ns}       - C_p \, \textit{emp} \lt. T \rt|_{k = 1})}^t \qquad
    F^S =               \frac{1}{\rho_o \lt. e_{3t} \rt|_{k = 1}}
          \overline{(\textit{sfx} -        \textit{emp} \lt. S \rt|_{k = 1})}^t
\end{equation}
Note that an exact conservation of heat and salt content is only achieved with
non-linear free surface.
In the linear free surface case, there is a small imbalance.
The imbalance is larger than the imbalance associated with the Asselin time filter
\citep{leclair.madec_OM09}.
This is the reason why the modified filter is not applied in the linear free surface case
(see \autoref{chap:TD}).

%% =================================================================================================
\subsection[Solar radiation penetration (\textit{traqsr.F90})]{Solar radiation penetration (\protect\mdl{traqsr})}
\label{subsec:TRA_qsr}

\begin{listing}
  \nlst{namtra_qsr}
  \caption{\forcode{&namtra_qsr}}
  \label{lst:namtra_qsr}
\end{listing}

Options are defined through the \nam{tra_qsr}{tra\_qsr} namelist variables.
When the penetrative solar radiation option is used (\np[=.true.]{ln_traqsr}{ln\_traqsr}),
the solar radiation penetrates the top few tens of meters of the ocean.
If it is not used (\np[=.false.]{ln_traqsr}{ln\_traqsr}) all the heat flux is absorbed in
the first ocean level.
Thus, in the former case a term is added to the time evolution equation of temperature
\autoref{eq:MB_PE_tra_T} and the surface boundary condition is modified to
take into account only the non-penetrative part of the surface heat flux:
\begin{equation}
  \label{eq:TRA_PE_qsr}
  \begin{gathered}
    \pd[T]{t} = \ldots + \frac{1}{\rho_o \, C_p \, e_3} \; \pd[I]{k} \\
    Q_{ns} = Q_\text{Total} - Q_{sr}
  \end{gathered}
\end{equation}
where $Q_{sr}$ is the penetrative part of the surface heat flux (\ie\ the shortwave radiation) and
$I$ is the downward irradiance ($\lt. I \rt|_{z = \eta} = Q_{sr}$).
The additional term in \autoref{eq:TRA_PE_qsr} is discretized as follows:
\begin{equation}
  \label{eq:TRA_qsr}
  \frac{1}{\rho_o \, C_p \, e_3} \, \pd[I]{k} \equiv \frac{1}{\rho_o \, C_p \, e_{3t}} \delta_k [I_w]
\end{equation}

The shortwave radiation, $Q_{sr}$, consists of energy distributed across a wide spectral range.
The ocean is strongly absorbing for wavelengths longer than 700 $nm$ and
these wavelengths contribute to heat the upper few tens of centimetres.
The fraction of $Q_{sr}$ that resides in these almost non-penetrative wavebands, $R$, is $\sim$ 58\%
(specified through namelist parameter \np{rn_abs}{rn\_abs}).
It is assumed to penetrate the ocean with a decreasing exponential profile,
with an e-folding depth scale, $\xi_0$, of a few tens of centimetres
(typically $\xi_0 = 0.35~m$ set as \np{rn_si0}{rn\_si0} in the \nam{tra_qsr}{tra\_qsr} namelist).
For shorter wavelengths (400-700 $nm$), the ocean is more transparent,
and solar energy propagates to larger depths where it contributes to local heating.
The way this second part of the solar energy penetrates into
the ocean depends on which formulation is chosen.
In the simple 2-waveband light penetration scheme (\np[=.true.]{ln_qsr_2bd}{ln\_qsr\_2bd})
a chlorophyll-independent monochromatic formulation is chosen for the shorter wavelengths,
leading to the following expression \citep{paulson.simpson_JPO77}:
\[
  % \label{eq:TRA_qsr_iradiance}
  I(z) = Q_{sr} \lt[ Re^{- z / \xi_0} + (1 - R) e^{- z / \xi_1} \rt]
\]
where $\xi_1$ is the second extinction length scale associated with the shorter wavelengths.
It is usually chosen to be 23~m by setting the \np{rn_si0}{rn\_si0} namelist parameter.
The set of default values ($\xi_0, \xi_1, R$) corresponds to
a Type I water in Jerlov's (1968) classification (oligotrophic waters).

Such assumptions have been shown to provide a very crude and simplistic representation of
observed light penetration profiles (\cite{morel_JGR88}, see also \autoref{fig:TRA_qsr_irradiance}).
Light absorption in the ocean depends on particle concentration and is spectrally selective.
\cite{morel_JGR88} has shown that an accurate representation of light penetration can be provided by
a 61 waveband formulation.
Unfortunately, such a model is very computationally expensive.
Thus, \cite{lengaigne.menkes.ea_CD07} have constructed a simplified version of
this formulation in which visible light is split into three wavebands:
blue (400-500 $nm$), green (500-600 $nm$) and red (600-700 $nm$).
For each wave-band, the chlorophyll-dependent attenuation coefficient is fitted to
the coefficients computed from the full spectral model of \cite{morel_JGR88}
(as modified by \cite{morel.maritorena_JGR01}), assuming the same power-law relationship.
As shown in \autoref{fig:TRA_qsr_irradiance}, this formulation,
called RGB (\textbf{R}ed-\textbf{G}reen-\textbf{B}lue),
reproduces quite closely the light penetration profiles predicted by the full spectal model,
but with much greater computational efficiency.
The 2-bands formulation does not reproduce the full model very well.

The RGB formulation is used when \np[=.true.]{ln_qsr_rgb}{ln\_qsr\_rgb}.
The RGB attenuation coefficients (\ie\ the inverses of the extinction length scales) are
tabulated over 61 nonuniform chlorophyll classes ranging from 0.01 to 10 $g.Chl/L$
(see the routine \rou{trc\_oce\_rgb} in \mdl{trc\_oce} module).
Four types of chlorophyll can be chosen in the RGB formulation:

\begin{description}
\item [{\np[=0]{nn_chldta}{nn\_chldta}}] a constant 0.05 $g.Chl/L$ value everywhere;
\item [{\np[=1]{nn_chldta}{nn\_chldta}}] an observed time varying chlorophyll deduced from
  satellite surface ocean color measurement spread uniformly in the vertical direction;
\item [{\np[=2]{nn_chldta}{nn\_chldta}}] same as previous case except that
  a vertical profile of chlorophyl is used.
  Following \cite{morel.berthon_LO89},
  the profile is computed from the local surface chlorophyll value;
\item [{\np[=.true.]{ln_qsr_bio}{ln\_qsr\_bio}}] simulated time varying chlorophyll by
  \TOP\ biogeochemical model.
  In this case, the RGB formulation is used to calculate both
  the phytoplankton light limitation in \PISCES\ and the oceanic heating rate.
\end{description}

A new 5-bands scheme is also available (\np[=.true.]{ln_qsr_5bd}{ln\_qsr\_5bd}).
It is an extension of the RGB scheme by adding a fifth ultra-violet component (UV) to the 4 other wavebands.
As for the RGB scheme, the UV waveband follows the same power-law as described in \cite{morel_JGR88} and \cite{morel.maritorena_JGR01}.
The chlorophyll-dependent attenuation coefficients are also derived from these articles.
The proportion of each band is set up in the namelist by using \np{rn_abs}{rn\_abs} to define the near-infrared proportion and
\np{rn_par}{rn\_par} to define the visible proportion. The UV proportion is then simply determined by $1 - rn\_abs - rn\_par$.

The trend in \autoref{eq:TRA_qsr} associated with the penetration of the solar radiation is added to
the temperature trend, and the surface heat flux is modified in routine \mdl{traqsr}.

When the $z$-coordinate is preferred to the $s$-coordinate,
the depth of $w-$levels does not significantly vary with location.
The level at which the light has been totally absorbed
(\ie\ it is less than the computer precision) is computed once,
and the trend associated with the penetration of the solar radiation is only added down to that level.
Finally, note that when the ocean is shallow ($<$ 200~m),
part of the solar radiation can reach the ocean floor.
In this case, we have chosen that all remaining radiation is absorbed in the last ocean level
(\ie\ $I$ is masked).

\begin{figure}
  \centering
  \includegraphics[width=0.66\textwidth]{TRA_Irradiance}
  \caption[Penetration profile of the downward solar irradiance calculated by four models]{
    Penetration profile of the downward solar irradiance calculated by four models.
    Two waveband chlorophyll-independent formulation (blue),
    a chlorophyll-dependent monochromatic formulation (green),
    4 waveband RGB formulation (red),
    61 waveband Morel (1988) formulation (black) for a chlorophyll concentration of
    (a) Chl=0.05 $mg/m^3$ and (b) Chl=0.5 $mg/m^3$.
    From \citet{lengaigne.menkes.ea_CD07}.}
  \label{fig:TRA_qsr_irradiance}
\end{figure}

%% =================================================================================================
\subsection[Bottom boundary condition (\textit{trabbc.F90}) - \forcode{ln_trabbc})]{Bottom boundary condition (\protect\mdl{trabbc} - \protect\np{ln_trabbc}{ln\_trabbc})}
\label{subsec:TRA_bbc}