New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
chap_DOM.tex in NEMO/trunk/doc/latex/NEMO/subfiles – NEMO

source: NEMO/trunk/doc/latex/NEMO/subfiles/chap_DOM.tex @ 11598

Last change on this file since 11598 was 11598, checked in by nicolasmartin, 5 years ago

Add template of versioning record at the beginning of chapters

File size: 36.0 KB
Line 
1\documentclass[../main/NEMO_manual]{subfiles}
2
3\begin{document}
4
5\chapter{Space Domain (DOM)}
6\label{chap:DOM}
7
8% Missing things:
9%  - istate: description of the initial state   ==> this has to be put elsewhere..
10%                  perhaps in MISC ?  By the way the initialisation of T S and dynamics
11%                  should be put outside of DOM routine (better with TRC staff and off-line
12%                  tracers)
13%  -geo2ocean:  how to switch from geographic to mesh coordinate
14%     - domclo:  closed sea and lakes.... management of closea sea area : specific to global configuration, both forced and coupled
15
16%    {\em 4.0} & {\em Simon M\"{u}ller \& Andrew Coward} &
17%    {\em
18%      Compatibility changes Major simplification has moved many of the options to external domain configuration tools.
19%      (see \autoref{apdx:DOMCFG})
20%    }                                                                                            \\
21%    {\em 3.x} & {\em Rachid Benshila, Gurvan Madec \& S\'{e}bastien Masson} &
22%    {\em First version}                                                                          \\
23
24\thispagestyle{plain}
25
26\chaptertoc
27
28\paragraph{Changes record} ~\\
29
30{\footnotesize
31  \begin{tabularx}{\textwidth}{l||X|X}
32    Release & Author(s) & Modifications \\
33    \hline
34    {\em   4.0} & {\em ...} & {\em ...} \\
35    {\em   3.6} & {\em ...} & {\em ...} \\
36    {\em   3.4} & {\em ...} & {\em ...} \\
37    {\em <=3.4} & {\em ...} & {\em ...}
38  \end{tabularx}
39}
40
41\clearpage
42
43Having defined the continuous equations in \autoref{chap:MB} and chosen a time discretisation \autoref{chap:TD},
44we need to choose a grid for spatial discretisation and related numerical algorithms.
45In the present chapter, we provide a general description of the staggered grid used in \NEMO,
46and other relevant information about the DOM (DOMain) source code modules.
47
48%% =================================================================================================
49\section{Fundamentals of the discretisation}
50\label{sec:DOM_basics}
51
52%% =================================================================================================
53\subsection{Arrangement of variables}
54\label{subsec:DOM_cell}
55
56\begin{figure}[!tb]
57  \centering
58  \includegraphics[width=0.66\textwidth]{Fig_cell}
59  \caption[Arrangement of variables in the unit cell of space domain]{
60    Arrangement of variables in the unit cell of space domain.
61    $t$ indicates scalar points where
62    temperature, salinity, density, pressure and horizontal divergence are defined.
63    $(u,v,w)$ indicates vector points,
64    and $f$ indicates vorticity points where
65    both relative and planetary vorticities are defined.}
66  \label{fig:DOM_cell}
67\end{figure}
68
69The numerical techniques used to solve the Primitive Equations in this model are based on the traditional,
70centred second-order finite difference approximation.
71Special attention has been given to the homogeneity of the solution in the three spatial directions.
72The arrangement of variables is the same in all directions.
73It consists of cells centred on scalar points ($t$, $S$, $p$, $\rho$) with vector points $(u, v, w)$ defined in
74the centre of each face of the cells (\autoref{fig:DOM_cell}).
75This is the generalisation to three dimensions of the well-known ``C'' grid in Arakawa's classification
76\citep{mesinger.arakawa_bk76}.
77The relative and planetary vorticity, $\zeta$ and $f$, are defined in the centre of each vertical edge and
78the barotropic stream function $\psi$ is defined at horizontal points overlying the $\zeta$ and $f$-points.
79
80The ocean mesh (\ie\ the position of all the scalar and vector points) is defined by the transformation that
81gives $(\lambda,\varphi,z)$ as a function of $(i,j,k)$.
82The grid-points are located at integer or integer and a half value of $(i,j,k)$ as indicated on \autoref{tab:DOM_cell}.
83In all the following, subscripts $u$, $v$, $w$, $f$, $uw$, $vw$ or $fw$ indicate the position of
84the grid-point where the scale factors are defined.
85Each scale factor is defined as the local analytical value provided by \autoref{eq:MB_scale_factors}.
86As a result, the mesh on which partial derivatives $\pd[]{\lambda}$, $\pd[]{\varphi}$ and
87$\pd[]{z}$ are evaluated is a uniform mesh with a grid size of unity.
88Discrete partial derivatives are formulated by the traditional, centred second order finite difference approximation
89while the scale factors are chosen equal to their local analytical value.
90An important point here is that the partial derivative of the scale factors must be evaluated by
91centred finite difference approximation, not from their analytical expression.
92This preserves the symmetry of the discrete set of equations and therefore satisfies many of
93the continuous properties (see \autoref{apdx:INVARIANTS}).
94A similar, related remark can be made about the domain size:
95when needed, an area, volume, or the total ocean depth must be evaluated as the product or sum of the relevant scale factors
96(see \autoref{eq:DOM_bar} in the next section).
97
98\begin{table}[!tb]
99  \centering
100  \begin{tabular}{|p{46pt}|p{56pt}|p{56pt}|p{56pt}|}
101    \hline
102    t & $i      $ & $j      $ & $k      $ \\
103    \hline
104    u & $i + 1/2$ & $j      $ & $k      $ \\
105    \hline
106    v & $i      $ & $j + 1/2$ & $k      $ \\
107    \hline
108    w & $i      $ & $j      $ & $k + 1/2$ \\
109    \hline
110    f & $i + 1/2$ & $j + 1/2$ & $k      $ \\
111    \hline
112    uw   & $i + 1/2$ & $j      $ & $k + 1/2$ \\
113    \hline
114    vw   & $i      $ & $j + 1/2$ & $k + 1/2$ \\
115    \hline
116    fw   & $i + 1/2$ & $j + 1/2$ & $k + 1/2$ \\
117    \hline
118  \end{tabular}
119  \caption[Location of grid-points]{
120    Location of grid-points as a function of integer or
121    integer and a half value of the column, line or level.
122    This indexing is only used for the writing of the semi -discrete equations.
123    In the code, the indexing uses integer values only and
124    is positive downwards in the vertical with $k=1$ at the surface.
125    (see \autoref{subsec:DOM_Num_Index})}
126  \label{tab:DOM_cell}
127\end{table}
128
129Note that the definition of the scale factors
130(\ie\ as the analytical first derivative of the transformation that
131results in $(\lambda,\varphi,z)$ as a function of $(i,j,k)$)
132is specific to the \NEMO\ model \citep{marti.madec.ea_JGR92}.
133As an example, a scale factor in the $i$ direction is defined locally at a $t$-point,
134whereas many other models on a C grid choose to define such a scale factor as
135the distance between the $u$-points on each side of the $t$-point.
136Relying on an analytical transformation has two advantages:
137firstly, there is no ambiguity in the scale factors appearing in the discrete equations,
138since they are first introduced in the continuous equations;
139secondly, analytical transformations encourage good practice by the definition of smoothly varying grids
140(rather than allowing the user to set arbitrary jumps in thickness between adjacent layers) \citep{treguier.dukowicz.ea_JGR96}.
141An example of the effect of such a choice is shown in \autoref{fig:DOM_zgr_e3}.
142\begin{figure}[!t]
143  \centering
144  \includegraphics[width=0.66\textwidth]{Fig_zgr_e3}
145  \caption[Comparison of grid-point position, vertical grid-size and scale factors]{
146    Comparison of (a) traditional definitions of grid-point position and grid-size in the vertical,
147    and (b) analytically derived grid-point position and scale factors.
148    For both grids here, the same $w$-point depth has been chosen but
149    in (a) the $t$-points are set half way between $w$-points while
150    in (b) they are defined from an analytical function:
151    $z(k) = 5 \, (k - 1/2)^3 - 45 \, (k - 1/2)^2 + 140 \, (k - 1/2) - 150$.
152    Note the resulting difference between the value of the grid-size $\Delta_k$ and
153    those of the scale factor $e_k$.}
154  \label{fig:DOM_zgr_e3}
155\end{figure}
156
157%% =================================================================================================
158\subsection{Discrete operators}
159\label{subsec:DOM_operators}
160
161Given the values of a variable $q$ at adjacent points, the differencing and averaging operators at
162the midpoint between them are:
163\begin{alignat*}{2}
164  % \label{eq:DOM_di_mi}
165  \delta_i [q]      &= &       &q (i + 1/2) - q (i - 1/2) \\
166  \overline q^{\, i} &= &\big\{ &q (i + 1/2) + q (i - 1/2) \big\} / 2
167\end{alignat*}
168
169Similar operators are defined with respect to $i + 1/2$, $j$, $j + 1/2$, $k$, and $k + 1/2$.
170Following \autoref{eq:MB_grad} and \autoref{eq:MB_lap}, the gradient of a variable $q$ defined at a $t$-point has
171its three components defined at $u$-, $v$- and $w$-points while its Laplacian is defined at the $t$-point.
172These operators have the following discrete forms in the curvilinear $s$-coordinates system:
173\[
174  % \label{eq:DOM_grad}
175  \nabla q \equiv   \frac{1}{e_{1u}} \delta_{i + 1/2} [q] \; \, \vect i
176                  + \frac{1}{e_{2v}} \delta_{j + 1/2} [q] \; \, \vect j
177                  + \frac{1}{e_{3w}} \delta_{k + 1/2} [q] \; \, \vect k
178\]
179\begin{multline*}
180  % \label{eq:DOM_lap}
181  \Delta q \equiv   \frac{1}{e_{1t} \, e_{2t} \, e_{3t}}
182                    \; \lt[   \delta_i \lt( \frac{e_{2u} \, e_{3u}}{e_{1u}} \; \delta_{i + 1/2} [q] \rt)
183                            + \delta_j \lt( \frac{e_{1v} \, e_{3v}}{e_{2v}} \; \delta_{j + 1/2} [q] \rt) \; \rt] \\
184                  + \frac{1}{e_{3t}}
185                              \delta_k \lt[ \frac{1              }{e_{3w}} \; \delta_{k + 1/2} [q] \rt]
186\end{multline*}
187
188Following \autoref{eq:MB_curl} and \autoref{eq:MB_div}, a vector $\vect A = (a_1,a_2,a_3)$ defined at
189vector points $(u,v,w)$ has its three curl components defined at $vw$-, $uw$, and $f$-points, and
190its divergence defined at $t$-points:
191\begin{multline}
192% \label{eq:DOM_curl}
193  \nabla \times \vect A \equiv   \frac{1}{e_{2v} \, e_{3vw}}
194                                 \Big[   \delta_{j + 1/2} (e_{3w} \, a_3)
195                                       - \delta_{k + 1/2} (e_{2v} \, a_2) \Big] \vect i \\
196                               + \frac{1}{e_{2u} \, e_{3uw}}
197                                 \Big[   \delta_{k + 1/2} (e_{1u} \, a_1)
198                                       - \delta_{i + 1/2} (e_{3w} \, a_3) \Big] \vect j \\
199                               + \frac{1}{e_{1f} \, e_{2f}}
200                                 \Big[   \delta_{i + 1/2} (e_{2v} \, a_2)
201                                       - \delta_{j + 1/2} (e_{1u} \, a_1) \Big] \vect k
202\end{multline}
203\begin{equation}
204% \label{eq:DOM_div}
205  \nabla \cdot \vect A \equiv   \frac{1}{e_{1t} \, e_{2t} \, e_{3t}}
206                                \Big[ \delta_i (e_{2u} \, e_{3u} \, a_1) + \delta_j (e_{1v} \, e_{3v} \, a_2) \Big]
207                              + \frac{1}{e_{3t}} \delta_k (a_3)
208\end{equation}
209
210The vertical average over the whole water column is denoted by an overbar and is for
211a masked field $q$ (\ie\ a quantity that is equal to zero inside solid areas):
212\begin{equation}
213  \label{eq:DOM_bar}
214  \bar q = \frac{1}{H} \int_{k^b}^{k^o} q \; e_{3q} \, dk \equiv \frac{1}{H_q} \sum \limits_k q \; e_{3q}
215\end{equation}
216where $H_q$  is the ocean depth, which is the masked sum of the vertical scale factors at $q$ points,
217$k^b$ and $k^o$ are the bottom and surface $k$-indices, and the symbol $\sum \limits_k$ refers to a summation over
218all grid points of the same type in the direction indicated by the subscript (here $k$).
219
220In continuous form, the following properties are satisfied:
221\begin{gather}
222  \label{eq:DOM_curl_grad}
223  \nabla \times \nabla q = \vect 0 \\
224  \label{eq:DOM_div_curl}
225  \nabla \cdot (\nabla \times \vect A) = 0
226\end{gather}
227
228It is straightforward to demonstrate that these properties are verified locally in discrete form as soon as
229the scalar $q$ is taken at $t$-points and the vector $\vect A$ has its components defined at
230vector points $(u,v,w)$.
231
232Let $a$ and $b$ be two fields defined on the mesh, with a value of zero inside continental areas.
233It can be shown that the differencing operators ($\delta_i$, $\delta_j$ and $\delta_k$)
234are skew-symmetric linear operators, and further that the averaging operators $\overline{\cdots}^{\, i}$,
235$\overline{\cdots}^{\, j}$ and $\overline{\cdots}^{\, k}$) are symmetric linear operators, \ie
236\begin{alignat}{4}
237  \label{eq:DOM_di_adj}
238  &\sum \limits_i a_i \; \delta_i [b]      &\equiv &- &&\sum \limits_i \delta      _{   i + 1/2} [a] &b_{i + 1/2} \\
239  \label{eq:DOM_mi_adj}
240  &\sum \limits_i a_i \; \overline b^{\, i} &\equiv &  &&\sum \limits_i \overline a ^{\, i + 1/2}     &b_{i + 1/2}
241\end{alignat}
242
243In other words, the adjoint of the differencing and averaging operators are $\delta_i^* = \delta_{i + 1/2}$ and
244$(\overline{\cdots}^{\, i})^* = \overline{\cdots}^{\, i + 1/2}$, respectively.
245These two properties will be used extensively in the \autoref{apdx:INVARIANTS} to
246demonstrate integral conservative properties of the discrete formulation chosen.
247
248%% =================================================================================================
249\subsection{Numerical indexing}
250\label{subsec:DOM_Num_Index}
251
252\begin{figure}[!tb]
253  \centering
254  \includegraphics[width=0.66\textwidth]{Fig_index_hor}
255  \caption[Horizontal integer indexing]{
256    Horizontal integer indexing used in the \fortran\ code.
257    The dashed area indicates the cell in which
258    variables contained in arrays have the same $i$- and $j$-indices}
259  \label{fig:DOM_index_hor}
260\end{figure}
261
262The array representation used in the \fortran\ code requires an integer indexing.
263However, the analytical definition of the mesh (see \autoref{subsec:DOM_cell}) is associated with the use of
264integer values for $t$-points only while all the other points involve integer and a half values.
265Therefore, a specific integer indexing has been defined for points other than $t$-points
266(\ie\ velocity and vorticity grid-points).
267Furthermore, the direction of the vertical indexing has been reversed and the surface level set at $k = 1$.
268
269%% =================================================================================================
270\subsubsection{Horizontal indexing}
271\label{subsec:DOM_Num_Index_hor}
272
273The indexing in the horizontal plane has been chosen as shown in \autoref{fig:DOM_index_hor}.
274For an increasing $i$ index ($j$ index),
275the $t$-point and the eastward $u$-point (northward $v$-point) have the same index
276(see the dashed area in \autoref{fig:DOM_index_hor}).
277A $t$-point and its nearest north-east $f$-point have the same $i$-and $j$-indices.
278
279%% =================================================================================================
280\subsubsection{Vertical indexing}
281\label{subsec:DOM_Num_Index_vertical}
282
283In the vertical, the chosen indexing requires special attention since the direction of the $k$-axis in
284the \fortran\ code is the reverse of that used in the semi -discrete equations and
285given in \autoref{subsec:DOM_cell}.
286The sea surface corresponds to the $w$-level $k = 1$, which is the same index as the $t$-level just below
287(\autoref{fig:DOM_index_vert}).
288The last $w$-level ($k = jpk$) either corresponds to or is below the ocean floor while
289the last $t$-level is always outside the ocean domain (\autoref{fig:DOM_index_vert}).
290Note that a $w$-point and the directly underlaying $t$-point have a common $k$ index
291(\ie\ $t$-points and their nearest $w$-point neighbour in negative index direction),
292in contrast to the indexing on the horizontal plane where the $t$-point has the same index as
293the nearest velocity points in the positive direction of the respective horizontal axis index
294(compare the dashed area in \autoref{fig:DOM_index_hor} and \autoref{fig:DOM_index_vert}).
295Since the scale factors are chosen to be strictly positive,
296a \textit{minus sign} is included in the \fortran\ implementations of
297\textit{all the vertical derivatives} of the discrete equations given in this manual in order to
298accommodate the opposing vertical index directions in implementation and documentation.
299
300\begin{figure}[!pt]
301  \centering
302  \includegraphics[width=0.66\textwidth]{Fig_index_vert}
303  \caption[Vertical integer indexing]{
304    Vertical integer indexing used in the \fortran\ code.
305    Note that the $k$-axis is oriented downward.
306    The dashed area indicates the cell in which
307    variables contained in arrays have a common $k$-index.}
308  \label{fig:DOM_index_vert}
309\end{figure}
310
311%% =================================================================================================
312\section{Spatial domain configuration}
313\label{subsec:DOM_config}
314
315Two typical methods are available to specify the spatial domain configuration;
316they can be selected using parameter \np{ln_read_cfg}{ln\_read\_cfg} parameter in namelist \nam{cfg}{cfg}.
317
318If \np{ln_read_cfg}{ln\_read\_cfg} is set to \forcode{.true.},
319the domain-specific parameters and fields are read from a netCDF input file,
320whose name (without its .nc suffix) can be specified as the value of the \np{cn_domcfg}{cn\_domcfg} parameter in namelist \nam{cfg}{cfg}.
321
322If \np{ln_read_cfg}{ln\_read\_cfg} is set to \forcode{.false.},
323the domain-specific parameters and fields can be provided (\eg\ analytically computed) by
324subroutines \mdl{usrdef\_hgr} and \mdl{usrdef\_zgr}.
325These subroutines can be supplied in the \path{MY_SRC} directory of the configuration,
326and default versions that configure the spatial domain for the GYRE reference configuration are present in
327the \path{./src/OCE/USR} directory.
328
329In version 4.0 there are no longer any options for reading complex bathymetries and
330performing a vertical discretisation at run-time.
331Whilst it is occasionally convenient to have a common bathymetry file and, for example,
332to run similar models with and without partial bottom boxes and/or sigma-coordinates,
333supporting such choices leads to overly complex code.
334Worse still is the difficulty of ensuring the model configurations intended to be identical are indeed so when
335the model domain itself can be altered by runtime selections.
336The code previously used to perform vertical discretisation has been incorporated into an external tool
337(\path{./tools/DOMAINcfg}) which is briefly described in \autoref{apdx:DOMCFG}.
338
339The next subsections summarise the parameter and fields related to the configuration of the whole model domain.
340These represent the minimum information that must be provided either via the \np{cn_domcfg}{cn\_domcfg} file or set by code
341inserted into user-supplied versions of the \texttt{usrdef\_*} subroutines.
342The requirements are presented in three sections:
343the domain size (\autoref{subsec:DOM_size}), the horizontal mesh (\autoref{subsec:DOM_hgr}),
344and the vertical grid (\autoref{subsec:DOM_zgr}).
345
346%% =================================================================================================
347\subsection{Domain size}
348\label{subsec:DOM_size}
349
350The total size of the computational domain is set by the parameters \jp{jpiglo}, \jp{jpjglo} and \jp{jpkglo} for
351the $i$, $j$ and $k$ directions, respectively.
352Note, that the variables \texttt{jpi} and \texttt{jpj} refer to the size of each processor subdomain when
353the code is run in parallel using domain decomposition (\key{mpp\_mpi} defined,
354see \autoref{sec:LBC_mpp}).
355
356The name of the configuration is set through parameter \np{cn_cfg}{cn\_cfg},
357and the nominal resolution through parameter \np{nn_cfg}{nn\_cfg}
358(unless in the input file both of variables \texttt{ORCA} and \texttt{ORCA\_index} are present,
359in which case \np{cn_cfg}{cn\_cfg} and \np{nn_cfg}{nn\_cfg} are set from these values accordingly).
360
361The global lateral boundary condition type is selected from 8 options using parameter \jp{jperio}.
362See \autoref{sec:LBC_jperio} for details on the available options and the corresponding values for \jp{jperio}.
363
364%% =================================================================================================
365\subsection[Horizontal grid mesh (\textit{domhgr.F90}]{Horizontal grid mesh (\protect\mdl{domhgr})}
366\label{subsec:DOM_hgr}
367
368%% =================================================================================================
369\subsubsection{Required fields}
370\label{sec:DOM_hgr_fields}
371
372The explicit specification of a range of mesh-related fields are required for the definition of a configuration.
373These include:
374
375\begin{clines}
376int    jpiglo, jpjglo, jpkglo            /* global domain sizes                                          */
377int    jperio                            /* lateral global domain b.c.                                   */
378double glamt, glamu, glamv, glamf        /* geographic longitude (t,u,v and f points respectively)       */
379double gphit, gphiu, gphiv, gphif        /* geographic latitude                                          */
380double e1t, e1u, e1v, e1f                /* horizontal scale factors                                     */
381double e2t, e2u, e2v, e2f                /* horizontal scale factors                                     */
382\end{clines}
383
384The values of the geographic longitude and latitude arrays at indices $i,j$ correspond to
385the analytical expressions of the longitude $\lambda$ and latitude $\varphi$ as a function of $(i,j)$,
386evaluated at the values as specified in \autoref{tab:DOM_cell} for the respective grid-point position.
387The calculation of the values of the horizontal scale factor arrays in general additionally involves
388partial derivatives of $\lambda$ and $\varphi$ with respect to $i$ and $j$,
389evaluated for the same arguments as $\lambda$ and $\varphi$.
390
391%% =================================================================================================
392\subsubsection{Optional fields}
393
394\begin{clines}
395                                         /* Optional:                                                    */
396int    ORCA, ORCA_index                  /* configuration name, configuration resolution                 */
397double e1e2u, e1e2v                      /* U and V surfaces (if grid size reduction in some straits)    */
398double ff_f, ff_t                        /* Coriolis parameter (if not on the sphere)                    */
399\end{clines}
400
401\NEMO\ can support the local reduction of key strait widths by
402altering individual values of e2u or e1v at the appropriate locations.
403This is particularly useful for locations such as Gibraltar or Indonesian Throughflow pinch-points
404(see \autoref{sec:MISC_strait} for illustrated examples).
405The key is to reduce the faces of $T$-cell (\ie\ change the value of the horizontal scale factors at $u$- or $v$-point) but
406not the volume of the cells.
407Doing otherwise can lead to numerical instability issues.
408In normal operation the surface areas are computed from $e1u * e2u$ and $e1v * e2v$ but
409in cases where a gridsize reduction is required,
410the unaltered surface areas at $u$ and $v$ grid points (\texttt{e1e2u} and \texttt{e1e2v}, respectively) must be read or
411pre-computed in \mdl{usrdef\_hgr}.
412If these arrays are present in the \np{cn_domcfg}{cn\_domcfg} file they are read and the internal computation is suppressed.
413Versions of \mdl{usrdef\_hgr} which set their own values of \texttt{e1e2u} and \texttt{e1e2v} should set
414the surface-area computation flag:
415\texttt{ie1e2u\_v} to a non-zero value to suppress their re-computation.
416
417\smallskip
418Similar logic applies to the other optional fields:
419\texttt{ff\_f} and \texttt{ff\_t} which can be used to provide the Coriolis parameter at F- and T-points respectively if
420the mesh is not on a sphere.
421If present these fields will be read and used and the normal calculation ($2 * \Omega * \sin(\varphi)$) suppressed.
422Versions of \mdl{usrdef\_hgr} which set their own values of \texttt{ff\_f} and \texttt{ff\_t} should set
423the Coriolis computation flag:
424\texttt{iff} to a non-zero value to suppress their re-computation.
425
426Note that longitudes, latitudes, and scale factors at $w$ points are exactly equal to those of $t$ points,
427thus no specific arrays are defined at $w$ points.
428
429%% =================================================================================================
430\subsection[Vertical grid (\textit{domzgr.F90})]{Vertical grid (\protect\mdl{domzgr})}
431\label{subsec:DOM_zgr}
432\begin{listing}
433  \nlst{namdom}
434  \caption{\forcode{&namdom}}
435  \label{lst:namdom}
436\end{listing}
437
438In the vertical, the model mesh is determined by four things:
439\begin{enumerate}
440  \item the bathymetry given in meters;
441  \item the number of levels of the model (\jp{jpk});
442  \item the analytical transformation $z(i,j,k)$ and the vertical scale factors (derivatives of the transformation); and
443  \item the masking system, \ie\ the number of wet model levels at each
444$(i,j)$ location of the horizontal grid.
445\end{enumerate}
446
447\begin{figure}[!tb]
448  \centering
449  \includegraphics[width=0.66\textwidth]{Fig_z_zps_s_sps}
450  \caption[Ocean bottom regarding coordinate systems ($z$, $s$ and hybrid $s-z$)]{
451    The ocean bottom as seen by the model:
452    (a) $z$-coordinate with full step,
453    (b) $z$-coordinate with partial step,
454    (c) $s$-coordinate: terrain following representation,
455    (d) hybrid $s-z$ coordinate,
456    (e) hybrid $s-z$ coordinate with partial step, and
457    (f) same as (e) but in the non-linear free surface (\protect\np[=.false.]{ln_linssh}{ln\_linssh}).
458    Note that the non-linear free surface can be used with any of the 5 coordinates (a) to (e).}
459  \label{fig:DOM_z_zps_s_sps}
460\end{figure}
461
462The choice of a vertical coordinate is made when setting up the configuration;
463it is not intended to be an option which can be changed in the middle of an experiment.
464The one exception to this statement being the choice of linear or non-linear free surface.
465In v4.0 the linear free surface option is implemented as a special case of the non-linear free surface.
466This is computationally wasteful since it uses the structures for time-varying 3D metrics
467for fields that (in the linear free surface case) are fixed.
468However, the linear free-surface is rarely used and implementing it this way means
469a single configuration file can support both options.
470
471By default a non-linear free surface is used (\np{ln_linssh}{ln\_linssh} set to \forcode{=.false.} in \nam{dom}{dom}):
472the coordinate follow the time-variation of the free surface so that the transformation is time dependent:
473$z(i,j,k,t)$ (\eg\ \autoref{fig:DOM_z_zps_s_sps}f).
474When a linear free surface is assumed (\np{ln_linssh}{ln\_linssh} set to \forcode{=.true.} in \nam{dom}{dom}),
475the vertical coordinates are fixed in time, but the seawater can move up and down across the $z_0$ surface
476(in other words, the top of the ocean in not a rigid lid).
477
478Note that settings:
479\np{ln_zco}{ln\_zco}, \np{ln_zps}{ln\_zps}, \np{ln_sco}{ln\_sco} and \np{ln_isfcav}{ln\_isfcav} mentioned in the following sections
480appear to be namelist options but they are no longer truly namelist options for \NEMO.
481Their value is written to and read from the domain configuration file and
482they should be treated as fixed parameters for a particular configuration.
483They are namelist options for the \texttt{DOMAINcfg} tool that can be used to build the configuration file and
484serve both to provide a record of the choices made whilst building the configuration and
485to trigger appropriate code blocks within \NEMO.
486These values should not be altered in the \np{cn_domcfg}{cn\_domcfg} file.
487
488\medskip
489The decision on these choices must be made when the \np{cn_domcfg}{cn\_domcfg} file is constructed.
490Three main choices are offered (\autoref{fig:DOM_z_zps_s_sps}a-c):
491
492\begin{itemize}
493\item $z$-coordinate with full step bathymetry (\np[=.true.]{ln_zco}{ln\_zco}),
494\item $z$-coordinate with partial step ($zps$) bathymetry (\np[=.true.]{ln_zps}{ln\_zps}),
495\item Generalized, $s$-coordinate (\np[=.true.]{ln_sco}{ln\_sco}).
496\end{itemize}
497
498Additionally, hybrid combinations of the three main coordinates are available:
499$s-z$ or $s-zps$ coordinate (\autoref{fig:DOM_z_zps_s_sps}d and \autoref{fig:DOM_z_zps_s_sps}e).
500
501A further choice related to vertical coordinate concerns
502the presence (or not) of ocean cavities beneath ice shelves within the model domain.
503A setting of \np{ln_isfcav}{ln\_isfcav} as \forcode{.true.} indicates that the domain contains ocean cavities,
504otherwise the top, wet layer of the ocean will always be at the ocean surface.
505This option is currently only available for $z$- or $zps$-coordinates.
506In the latter case, partial steps are also applied at the ocean/ice shelf interface.
507
508Within the model, the arrays describing the grid point depths and vertical scale factors are three set of
509three dimensional arrays $(i,j,k)$ defined at \textit{before}, \textit{now} and \textit{after} time step.
510The time at which they are defined is indicated by a suffix: $\_b$, $\_n$, or $\_a$, respectively.
511They are updated at each model time step.
512The initial fixed reference coordinate system is held in variable names with a $\_0$ suffix.
513When the linear free surface option is used (\np[=.true.]{ln_linssh}{ln\_linssh}),
514\textit{before}, \textit{now} and \textit{after} arrays are initially set to
515their reference counterpart and remain fixed.
516
517%% =================================================================================================
518\subsubsection{Required fields}
519\label{sec:DOM_zgr_fields}
520
521The explicit specification of a range of fields related to the vertical grid are required for
522the definition of a configuration.
523These include:
524
525\begin{clines}
526int    ln_zco, ln_zps, ln_sco            /* flags for z-coord, z-coord with partial steps and s-coord    */
527int    ln_isfcav                         /* flag  for ice shelf cavities                                 */
528double e3t_1d, e3w_1d                    /* reference vertical scale factors at T and W points           */
529double e3t_0, e3u_0, e3v_0, e3f_0, e3w_0 /* vertical scale factors 3D coordinate at T,U,V,F and W points */
530double e3uw_0, e3vw_0                    /* vertical scale factors 3D coordinate at UW and VW points     */
531int    bottom_level, top_level           /* last wet T-points, 1st wet T-points (for ice shelf cavities) */
532                                         /* For reference:                                               */
533float  bathy_metry                       /* bathymetry used in setting top and bottom levels             */
534\end{clines}
535
536This set of vertical metrics is sufficient to describe the initial depth and thickness of every gridcell in
537the model regardless of the choice of vertical coordinate.
538With constant z-levels, e3 metrics will be uniform across each horizontal level.
539In the partial step case each e3 at the \jp{bottom\_level}
540(and, possibly, \jp{top\_level} if ice cavities are present)
541may vary from its horizontal neighbours.
542And, in s-coordinates, variations can occur throughout the water column.
543With the non-linear free-surface, all the coordinates behave more like the s-coordinate in
544that variations occur throughout the water column with displacements related to the sea surface height.
545These variations are typically much smaller than those arising from bottom fitted coordinates.
546The values for vertical metrics supplied in the domain configuration file can be considered as
547those arising from a flat sea surface with zero elevation.
548
549The \jp{bottom\_level} and \jp{top\_level} 2D arrays define the \jp{bottom\_level} and top wet levels in each grid column.
550Without ice cavities, \jp{top\_level} is essentially a land mask (0 on land; 1 everywhere else).
551With ice cavities, \jp{top\_level} determines the first wet point below the overlying ice shelf.
552
553%% =================================================================================================
554\subsubsection{Level bathymetry and mask}
555\label{subsec:DOM_msk}
556
557From \jp{top\_level} and \jp{bottom\_level} fields, the mask fields are defined as follows:
558\begin{alignat*}{2}
559  tmask(i,j,k) &= &  &
560    \begin{cases}
561                  0 &\text{if $                  k  <    top\_level(i,j)$} \\
562                  1 &\text{if $bottom\_level(i,j) \leq k \leq   top\_level(i,j)$} \\
563                  0 &\text{if $                  k  >     bottom\_level(i,j)$}
564    \end{cases}
565  \\
566  umask(i,j,k) &= &  &tmask(i,j,k) * tmask(i + 1,j,    k) \\
567  vmask(i,j,k) &= &  &tmask(i,j,k) * tmask(i    ,j + 1,k) \\
568  fmask(i,j,k) &= &  &tmask(i,j,k) * tmask(i + 1,j,    k) \\
569               &  &* &tmask(i,j,k) * tmask(i + 1,j,    k) \\
570  wmask(i,j,k) &= &  &tmask(i,j,k) * tmask(i    ,j,k - 1) \\
571  \text{with~} wmask(i,j,1) &= & &tmask(i,j,1)
572\end{alignat*}
573
574Note that, without ice shelves cavities,
575masks at $t-$ and $w-$points are identical with the numerical indexing used (\autoref{subsec:DOM_Num_Index}).
576Nevertheless, $wmask$ are required with ocean cavities to deal with the top boundary (ice shelf/ocean interface)
577exactly in the same way as for the bottom boundary.
578
579%% The specification of closed lateral boundaries requires that at least
580%% the first and last rows and columns of the \textit{mbathy} array are set to zero.
581%% In the particular case of an east-west cyclical boundary condition, \textit{mbathy} has its last column equal to
582%% the second one and its first column equal to the last but one (and so too the mask arrays)
583%% (see \autoref{fig:LBC_jperio}).
584
585%        Closed seas
586%% =================================================================================================
587\subsection{Closed seas}
588\label{subsec:DOM_closea}
589
590When a global ocean is coupled to an atmospheric model it is better to represent all large water bodies
591(\eg\ Great Lakes, Caspian sea \dots) even if the model resolution does not allow their communication with
592the rest of the ocean.
593This is unnecessary when the ocean is forced by fixed atmospheric conditions,
594so these seas can be removed from the ocean domain.
595The user has the option to set the bathymetry in closed seas to zero (see \autoref{sec:MISC_closea}) and
596to optionally decide on the fate of any freshwater imbalance over the area.
597The options are explained in \autoref{sec:MISC_closea} but it should be noted here that
598a successful use of these options requires appropriate mask fields to be present in the domain configuration file.
599Among the possibilities are:
600
601\begin{clines}
602int    closea_mask          /* non-zero values in closed sea areas for optional masking                  */
603int    closea_mask_rnf      /* non-zero values in closed sea areas with runoff locations (precip only)   */
604int    closea_mask_emp      /* non-zero values in closed sea areas with runoff locations (total emp)     */
605\end{clines}
606
607%% =================================================================================================
608\subsection{Output grid files}
609\label{subsec:DOM_meshmask}
610
611Most of the arrays relating to a particular ocean model configuration discussed in this chapter
612(grid-point position, scale factors)
613can be saved in a file if
614namelist parameter \np{ln_write_cfg}{ln\_write\_cfg} (namelist \nam{cfg}{cfg}) is set to \forcode{.true.};
615the output filename is set through parameter \np{cn_domcfg_out}{cn\_domcfg\_out}.
616This is only really useful if
617the fields are computed in subroutines \mdl{usrdef\_hgr} or \mdl{usrdef\_zgr} and
618checking or confirmation is required.
619
620Alternatively, all the arrays relating to a particular ocean model configuration
621(grid-point position, scale factors, depths and masks)
622can be saved in a file called \texttt{mesh\_mask} if
623namelist parameter \np{ln_meshmask}{ln\_meshmask} (namelist \nam{dom}{dom}) is set to \forcode{.true.}.
624This file contains additional fields that can be useful for post-processing applications.
625
626%% =================================================================================================
627\section[Initial state (\textit{istate.F90} and \textit{dtatsd.F90})]{Initial state (\protect\mdl{istate} and \protect\mdl{dtatsd})}
628\label{sec:DOM_DTA_tsd}
629\begin{listing}
630  \nlst{namtsd}
631  \caption{\forcode{&namtsd}}
632  \label{lst:namtsd}
633\end{listing}
634
635Basic initial state options are defined in \nam{tsd}{tsd}.
636By default, the ocean starts from rest (the velocity field is set to zero) and
637the initialization of temperature and salinity fields is controlled through the \np{ln_tsd_init}{ln\_tsd\_init} namelist parameter.
638
639\begin{description}
640\item [{\np[=.true.]{ln_tsd_init}{ln\_tsd\_init}}] Use T and S input files that can be given on the model grid itself or on their native input data grids.
641  In the latter case, the data will be interpolated on-the-fly both in the horizontal and the vertical to the model grid
642  (see \autoref{subsec:SBC_iof}).
643  The information relating to the input files are specified in the \np{sn_tem}{sn\_tem} and \np{sn_sal}{sn\_sal} structures.
644  The computation is done in the \mdl{dtatsd} module.
645\item [{\np[=.false.]{ln_tsd_init}{ln\_tsd\_init}}] Initial values for T and S are set via a user supplied \rou{usr\_def\_istate} routine contained in \mdl{userdef\_istate}.
646  The default version sets horizontally uniform T and profiles as used in the GYRE configuration
647  (see \autoref{sec:CFGS_gyre}).
648\end{description}
649
650\onlyinsubfile{\input{../../global/epilogue}}
651
652\end{document}
Note: See TracBrowser for help on using the repository browser.