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 @ 11622

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

Review of "Time Domain" and DOM chapters

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