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_LBC.tex in NEMO/trunk/doc/latex/NEMO/subfiles – NEMO

source: NEMO/trunk/doc/latex/NEMO/subfiles/chap_LBC.tex @ 11582

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

New LaTeX commands \nam and \np to mention namelist content (step 2)
Finally convert \forcode{...} following \np{}{} into optional arg of the new command \np[]{}{}

File size: 43.7 KB
Line 
1\documentclass[../main/NEMO_manual]{subfiles}
2
3\onlyinsubfile{\makeindex}
4
5\begin{document}
6% ================================================================
7% Chapter — Lateral Boundary Condition (LBC)
8% ================================================================
9\chapter{Lateral Boundary Condition (LBC)}
10\label{chap:LBC}
11
12\chaptertoc
13
14\newpage
15
16%gm% add here introduction to this chapter
17
18% ================================================================
19% Boundary Condition at the Coast
20% ================================================================
21\section[Boundary condition at the coast (\forcode{rn_shlat})]{Boundary condition at the coast (\protect\np{rn_shlat}{rn\_shlat})}
22\label{sec:LBC_coast}
23%--------------------------------------------namlbc-------------------------------------------------------
24
25\begin{listing}
26  \nlst{namlbc}
27  \caption{\forcode{&namlbc}}
28  \label{lst:namlbc}
29\end{listing}
30%--------------------------------------------------------------------------------------------------------------
31
32%The lateral ocean boundary conditions contiguous to coastlines are Neumann conditions for heat and salt
33%(no flux across boundaries) and Dirichlet conditions for momentum (ranging from free-slip to "strong" no-slip).
34%They are handled automatically by the mask system (see \autoref{subsec:DOM_msk}).
35
36%OPA allows land and topography grid points in the computational domain due to the presence of continents or islands,
37%and includes the use of a full or partial step representation of bottom topography.
38%The computation is performed over the whole domain, \ie\ we do not try to restrict the computation to ocean-only points.
39%This choice has two motivations.
40%Firstly, working on ocean only grid points overloads the code and harms the code readability.
41%Secondly, and more importantly, it drastically reduces the vector portion of the computation,
42%leading to a dramatic increase of CPU time requirement on vector computers.
43%The current section describes how the masking affects the computation of the various terms of the equations
44%with respect to the boundary condition at solid walls.
45%The process of defining which areas are to be masked is described in \autoref{subsec:DOM_msk}.
46
47Options are defined through the \nam{lbc}{lbc} namelist variables.
48The discrete representation of a domain with complex boundaries (coastlines and bottom topography) leads to
49arrays that include large portions where a computation is not required as the model variables remain at zero.
50Nevertheless, vectorial supercomputers are far more efficient when computing over a whole array,
51and the readability of a code is greatly improved when boundary conditions are applied in
52an automatic way rather than by a specific computation before or after each computational loop.
53An efficient way to work over the whole domain while specifying the boundary conditions,
54is to use multiplication by mask arrays in the computation.
55A mask array is a matrix whose elements are $1$ in the ocean domain and $0$ elsewhere.
56A simple multiplication of a variable by its own mask ensures that it will remain zero over land areas.
57Since most of the boundary conditions consist of a zero flux across the solid boundaries,
58they can be simply applied by multiplying variables by the correct mask arrays,
59\ie\ the mask array of the grid point where the flux is evaluated.
60For example, the heat flux in the \textbf{i}-direction is evaluated at $u$-points.
61Evaluating this quantity as,
62
63\[
64  % \label{eq:LBC_aaaa}
65  \frac{A^{lT} }{e_1 }\frac{\partial T}{\partial i}\equiv \frac{A_u^{lT}
66  }{e_{1u} } \; \delta_{i+1 / 2} \left[ T \right]\;\;mask_u
67\]
68(where mask$_{u}$ is the mask array at a $u$-point) ensures that the heat flux is zero inside land and
69at the boundaries, since mask$_{u}$ is zero at solid boundaries which in this case are defined at $u$-points
70(normal velocity $u$ remains zero at the coast) (\autoref{fig:LBC_uv}).
71
72%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
73\begin{figure}[!t]
74  \centering
75  \includegraphics[width=0.66\textwidth]{Fig_LBC_uv}
76  \caption[Lateral boundary at $T$-level]{
77    Lateral boundary (thick line) at T-level.
78    The velocity normal to the boundary is set to zero.}
79  \label{fig:LBC_uv}
80\end{figure}
81%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
82
83For momentum the situation is a bit more complex as two boundary conditions must be provided along the coast
84(one each for the normal and tangential velocities).
85The boundary of the ocean in the C-grid is defined by the velocity-faces.
86For example, at a given $T$-level,
87the lateral boundary (a coastline or an intersection with the bottom topography) is made of
88segments joining $f$-points, and normal velocity points are located between two $f-$points (\autoref{fig:LBC_uv}).
89The boundary condition on the normal velocity (no flux through solid boundaries)
90can thus be easily implemented using the mask system.
91The boundary condition on the tangential velocity requires a more specific treatment.
92This boundary condition influences the relative vorticity and momentum diffusive trends,
93and is required in order to compute the vorticity at the coast.
94Four different types of lateral boundary condition are available,
95controlled by the value of the \np{rn_shlat}{rn\_shlat} namelist parameter
96(The value of the mask$_{f}$ array along the coastline is set equal to this parameter).
97These are:
98
99%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
100\begin{figure}[!p]
101  \centering
102  \includegraphics[width=0.66\textwidth]{Fig_LBC_shlat}
103  \caption[Lateral boundary conditions]{
104    Lateral boundary conditions
105    (a) free-slip                       (\protect\np[=0]{rn_shlat}{rn\_shlat});
106    (b) no-slip                         (\protect\np[=2]{rn_shlat}{rn\_shlat});
107    (c) "partial" free-slip (\forcode{0<}\protect\np[<2]{rn_shlat}{rn\_shlat}) and
108    (d) "strong" no-slip    (\forcode{2<}\protect\np{rn_shlat}{rn\_shlat}).
109    Implied "ghost" velocity inside land area is display in grey.}
110  \label{fig:LBC_shlat}
111\end{figure}
112%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
113
114\begin{description}
115
116\item[free-slip boundary condition ({\np[=0]{rn_shlat}{rn\_shlat}})] the tangential velocity at
117  the coastline is equal to the offshore velocity,
118  \ie\ the normal derivative of the tangential velocity is zero at the coast,
119  so the vorticity: mask$_{f}$ array is set to zero inside the land and just at the coast
120  (\autoref{fig:LBC_shlat}-a).
121
122\item[no-slip boundary condition ({\np[=2]{rn_shlat}{rn\_shlat}})] the tangential velocity vanishes at the coastline.
123  Assuming that the tangential velocity decreases linearly from
124  the closest ocean velocity grid point to the coastline,
125  the normal derivative is evaluated as if the velocities at the closest land velocity gridpoint and
126  the closest ocean velocity gridpoint were of the same magnitude but in the opposite direction
127  (\autoref{fig:LBC_shlat}-b).
128  Therefore, the vorticity along the coastlines is given by:
129
130  \[
131    \zeta \equiv 2 \left(\delta_{i+1/2} \left[e_{2v} v \right] - \delta_{j+1/2} \left[e_{1u} u \right] \right) / \left(e_{1f} e_{2f} \right) \ ,
132  \]
133  where $u$ and $v$ are masked fields.
134  Setting the mask$_{f}$ array to $2$ along the coastline provides a vorticity field computed with
135  the no-slip boundary condition, simply by multiplying it by the mask$_{f}$ :
136  \[
137    % \label{eq:LBC_bbbb}
138    \zeta \equiv \frac{1}{e_{1f} {\kern 1pt}e_{2f} }\left( {\delta_{i+1/2}
139        \left[ {e_{2v} \,v} \right]-\delta_{j+1/2} \left[ {e_{1u} \,u} \right]}
140    \right)\;\mbox{mask}_f
141  \]
142
143\item["partial" free-slip boundary condition (0$<$\np{rn_shlat}{rn\_shlat}$<$2)] the tangential velocity at
144  the coastline is smaller than the offshore velocity, \ie\ there is a lateral friction but
145  not strong enough to make the tangential velocity at the coast vanish (\autoref{fig:LBC_shlat}-c).
146  This can be selected by providing a value of mask$_{f}$ strictly inbetween $0$ and $2$.
147
148\item["strong" no-slip boundary condition (2$<$\np{rn_shlat}{rn\_shlat})] the viscous boundary layer is assumed to
149  be smaller than half the grid size (\autoref{fig:LBC_shlat}-d).
150  The friction is thus larger than in the no-slip case.
151
152\end{description}
153
154Note that when the bottom topography is entirely represented by the $s$-coordinates (pure $s$-coordinate),
155the lateral boundary condition on tangential velocity is of much less importance as
156it is only applied next to the coast where the minimum water depth can be quite shallow.
157
158
159% ================================================================
160% Boundary Condition around the Model Domain
161% ================================================================
162\section[Model domain boundary condition (\forcode{jperio})]{Model domain boundary condition (\protect\jp{jperio})}
163\label{sec:LBC_jperio}
164
165At the model domain boundaries several choices are offered:
166closed, cyclic east-west, cyclic north-south, a north-fold, and combination closed-north fold or
167bi-cyclic east-west and north-fold.
168The north-fold boundary condition is associated with the 3-pole ORCA mesh.
169
170% -------------------------------------------------------------------------------------------------------------
171%        Closed, cyclic (\jp{jperio}\forcode{ = 0..2})
172% -------------------------------------------------------------------------------------------------------------
173\subsection[Closed, cyclic (\forcode{=0,1,2,7})]{Closed, cyclic (\protect\jp{jperio}\forcode{=0,1,2,7})}
174\label{subsec:LBC_jperio012}
175
176The choice of closed or cyclic model domain boundary condition is made by
177setting \jp{jperio} to 0, 1, 2 or 7 in namelist \nam{cfg}{cfg}.
178Each time such a boundary condition is needed, it is set by a call to routine \mdl{lbclnk}.
179The computation of momentum and tracer trends proceeds from $i=2$ to $i=jpi-1$ and from $j=2$ to $j=jpj-1$,
180\ie\ in the model interior.
181To choose a lateral model boundary condition is to specify the first and last rows and columns of
182the model variables.
183
184\begin{description}
185
186\item[For closed boundary (\jp{jperio}\forcode{=0})],
187  solid walls are imposed at all model boundaries:
188  first and last rows and columns are set to zero.
189
190\item[For cyclic east-west boundary (\jp{jperio}\forcode{=1})],
191  first and last rows are set to zero (closed) whilst the first column is set to
192  the value of the last-but-one column and the last column to the value of the second one
193  (\autoref{fig:LBC_jperio}-a).
194  Whatever flows out of the eastern (western) end of the basin enters the western (eastern) end.
195
196\item[For cyclic north-south boundary (\jp{jperio}\forcode{=2})],
197  first and last columns are set to zero (closed) whilst the first row is set to
198  the value of the last-but-one row and the last row to the value of the second one
199  (\autoref{fig:LBC_jperio}-a).
200  Whatever flows out of the northern (southern) end of the basin enters the southern (northern) end.
201
202\item[Bi-cyclic east-west and north-south boundary (\jp{jperio}\forcode{=7})] combines cases 1 and 2.
203
204\end{description}
205
206%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
207\begin{figure}[!t]
208  \centering
209  \includegraphics[width=0.66\textwidth]{Fig_LBC_jperio}
210  \caption[Setting of east-west cyclic and symmetric across the Equator boundary conditions]{
211    Setting of (a) east-west cyclic (b) symmetric across the Equator boundary conditions}
212  \label{fig:LBC_jperio}
213\end{figure}
214%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
215
216% -------------------------------------------------------------------------------------------------------------
217%        North fold (\textit{jperio = 3 }to $6)$
218% -------------------------------------------------------------------------------------------------------------
219\subsection[North-fold (\forcode{=3,6})]{North-fold (\protect\jp{jperio}\forcode{=3,6})}
220\label{subsec:LBC_north_fold}
221
222The north fold boundary condition has been introduced in order to handle the north boundary of
223a three-polar ORCA grid.
224Such a grid has two poles in the northern hemisphere (\autoref{fig:CFGS_ORCA_msh},
225and thus requires a specific treatment illustrated in \autoref{fig:LBC_North_Fold_T}.
226Further information can be found in \mdl{lbcnfd} module which applies the north fold boundary condition.
227
228%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
229\begin{figure}[!t]
230  \centering
231  \includegraphics[width=0.66\textwidth]{Fig_North_Fold_T}
232  \caption[North fold boundary in ORCA 2\deg, 1/4\deg and 1/12\deg]{
233    North fold boundary with a $T$-point pivot and cyclic east-west boundary condition ($jperio=4$),
234    as used in ORCA 2\deg, 1/4\deg and 1/12\deg.
235    Pink shaded area corresponds to the inner domain mask (see text).}
236  \label{fig:LBC_North_Fold_T}
237\end{figure}
238%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
239
240% ====================================================================
241% Exchange with neighbouring processors
242% ====================================================================
243\section[Exchange with neighbouring processors (\textit{lbclnk.F90}, \textit{lib\_mpp.F90})]{Exchange with neighbouring processors (\protect\mdl{lbclnk}, \protect\mdl{lib\_mpp})}
244\label{sec:LBC_mpp}
245
246%-----------------------------------------nammpp--------------------------------------------
247
248\begin{listing}
249  \nlst{nammpp}
250  \caption{\forcode{&nammpp}}
251  \label{lst:nammpp}
252\end{listing}
253%-----------------------------------------------------------------------------------------------
254
255For massively parallel processing (mpp), a domain decomposition method is used.
256The basic idea of the method is to split the large computation domain of a numerical experiment into several smaller domains and
257solve the set of equations by addressing independent local problems.
258Each processor has its own local memory and computes the model equation over a subdomain of the whole model domain.
259The subdomain boundary conditions are specified through communications between processors which are organized by
260explicit statements (message passing method).
261The present implementation is largely inspired by Guyon's work [Guyon 1995].
262
263The parallelization strategy is defined by the physical characteristics of the ocean model.
264Second order finite difference schemes lead to local discrete operators that
265depend at the very most on one neighbouring point.
266The only non-local computations concern the vertical physics
267(implicit diffusion, turbulent closure scheme, ...).
268Therefore, a pencil strategy is used for the data sub-structuration:
269the 3D initial domain is laid out on local processor memories following a 2D horizontal topological splitting.
270Each sub-domain computes its own surface and bottom boundary conditions and
271has a side wall overlapping interface which defines the lateral boundary conditions for
272computations in the inner sub-domain.
273The overlapping area consists of the two rows at each edge of the sub-domain.
274After a computation, a communication phase starts:
275each processor sends to its neighbouring processors the update values of the points corresponding to
276the interior overlapping area to its neighbouring sub-domain (\ie\ the innermost of the two overlapping rows).
277Communications are first done according to the east-west direction and next according to the north-south direction.
278There is no specific communications for the corners.
279The communication is done through the Message Passing Interface (MPI) and requires \key{mpp\_mpi}.
280Use also \key{mpi2} if MPI3 is not available on your computer.
281The data exchanges between processors are required at the very place where
282lateral domain boundary conditions are set in the mono-domain computation:
283the \rou{lbc\_lnk} routine (found in \mdl{lbclnk} module) which manages such conditions is interfaced with
284routines found in \mdl{lib\_mpp} module.
285The output file \textit{communication\_report.txt} provides the list of which routines do how
286many communications during 1 time step of the model.\\
287
288%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
289\begin{figure}[!t]
290  \centering
291  \includegraphics[width=0.66\textwidth]{Fig_mpp}
292  \caption{Positioning of a sub-domain when massively parallel processing is used}
293  \label{fig:LBC_mpp}
294\end{figure}
295%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
296
297In \NEMO, the splitting is regular and arithmetic.
298The total number of subdomains corresponds to the number of MPI processes allocated to \NEMO\ when the model is launched
299(\ie\ mpirun -np x ./nemo will automatically give x subdomains).
300The i-axis is divided by \np{jpni}{jpni} and the j-axis by \np{jpnj}{jpnj}.
301These parameters are defined in \nam{mpp}{mpp} namelist.
302If \np{jpni}{jpni} and \np{jpnj}{jpnj} are < 1, they will be automatically redefined in the code to give the best domain decomposition
303(see bellow).
304
305Each processor is independent and without message passing or synchronous process, programs run alone and access just its own local memory.
306For this reason,
307the main model dimensions are now the local dimensions of the subdomain (pencil) that are named \jp{jpi}, \jp{jpj}, \jp{jpk}.
308These dimensions include the internal domain and the overlapping rows.
309The number of rows to exchange (known as the halo) is usually set to one (nn\_hls=1, in \mdl{par\_oce},
310and must be kept to one until further notice).
311The whole domain dimensions are named \jp{jpiglo}, \jp{jpjglo} and \jp{jpk}.
312The relationship between the whole domain and a sub-domain is:
313\begin{gather*}
314  jpi = ( jpiglo-2\times nn\_hls + (jpni-1) ) / jpni + 2\times nn\_hls \\
315  jpj = ( jpjglo-2\times nn\_hls + (jpnj-1) ) / jpnj + 2\times nn\_hls
316\end{gather*}
317
318One also defines variables nldi and nlei which correspond to the internal domain bounds, and the variables nimpp and njmpp which are the position of the (1,1) grid-point in the global domain (\autoref{fig:LBC_mpp}). Note that since the version 4, there is no more extra-halo area as defined in \autoref{fig:LBC_mpp} so \jp{jpi} is now always equal to nlci and \jp{jpj} equal to nlcj.
319
320An element of $T_{l}$, a local array (subdomain) corresponds to an element of $T_{g}$,
321a global array (whole domain) by the relationship:
322\[
323  % \label{eq:LBC_nimpp}
324  T_{g} (i+nimpp-1,j+njmpp-1,k) = T_{l} (i,j,k),
325\]
326with $1 \leq i \leq jpi$, $1  \leq j \leq jpj $ , and  $1  \leq k \leq jpk$.
327
328The 1-d arrays $mig(1:\jp{jpi})$ and $mjg(1:\jp{jpj})$, defined in \rou{dom\_glo} routine (\mdl{domain} module), should be used to get global domain indices from local domain indices. The 1-d arrays, $mi0(1:\jp{jpiglo})$, $mi1(1:\jp{jpiglo})$ and $mj0(1:\jp{jpjglo})$, $mj1(1:\jp{jpjglo})$ have the reverse purpose and should be used to define loop indices expressed in global domain indices (see examples in \mdl{dtastd} module).\\
329
330The \NEMO\ model computes equation terms with the help of mask arrays (0 on land points and 1 on sea points). It is therefore possible that an MPI subdomain contains only land points. To save ressources, we try to supress from the computational domain as much land subdomains as possible. For example if $N_{mpi}$ processes are allocated to NEMO, the domain decomposition will be given by the following equation:
331\[
332  N_{mpi} = jpni \times jpnj - N_{land} + N_{useless}
333\]
334$N_{land}$ is the total number of land subdomains in the domain decomposition defined by \np{jpni}{jpni} and \np{jpnj}{jpnj}. $N_{useless}$ is the number of land subdomains that are kept in the compuational domain in order to make sure that $N_{mpi}$ MPI processes are indeed allocated to a given subdomain. The values of $N_{mpi}$, \np{jpni}{jpni}, \np{jpnj}{jpnj}$N_{land}$ and $N_{useless}$ are printed in the output file \texttt{ocean.output}. $N_{useless}$ must, of course, be as small as possible to limit the waste of ressources. A warning is issued in  \texttt{ocean.output} if $N_{useless}$ is not zero. Note that non-zero value of $N_{useless}$ is uselly required when using AGRIF as, up to now, the parent grid and each of the child grids must use all the $N_{mpi}$ processes.
335
336If the domain decomposition is automatically defined (when \np{jpni}{jpni} and \np{jpnj}{jpnj} are < 1), the decomposition chosen by the model will minimise the sub-domain size (defined as $max_{all domains}(jpi \times jpj)$) and maximize the number of eliminated land subdomains. This means that no other domain decomposition (a set of \np{jpni}{jpni} and \np{jpnj}{jpnj} values) will use less processes than $(jpni  \times  jpnj - N_{land})$ and get a smaller subdomain size.
337In order to specify $N_{mpi}$ properly (minimize $N_{useless}$), you must run the model once with \np{ln_list}{ln\_list} activated. In this case, the model will start the initialisation phase, print the list of optimum decompositions ($N_{mpi}$, \np{jpni}{jpni} and \np{jpnj}{jpnj}) in \texttt{ocean.output} and directly abort. The maximum value of $N_{mpi}$ tested in this list is given by $max(N_{MPI\_tasks}, jpni \times jpnj)$. For example, run the model on 40 nodes with ln\_list activated and $jpni = 10000$ and $jpnj = 1$, will print the list of optimum domains decomposition from 1 to about 10000.
338
339Processors are numbered from 0 to $N_{mpi} - 1$. Subdomains containning some ocean points are numbered first from 0 to $jpni * jpnj - N_{land} -1$. The remaining $N_{useless}$ land subdomains are numbered next, which means that, for a given (\np{jpni}{jpni}, \np{jpnj}{jpnj}), the numbers attributed to he ocean subdomains do not vary with $N_{useless}$.
340
341When land processors are eliminated, the value corresponding to these locations in the model output files is undefined. \np{ln_mskland}{ln\_mskland} must be activated in order avoid Not a Number values in output files. Note that it is better to not eliminate land processors when creating a meshmask file (\ie\ when setting a non-zero value to \np{nn_msh}{nn\_msh}).
342
343%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
344\begin{figure}[!ht]
345  \centering
346  \includegraphics[width=0.66\textwidth]{Fig_mppini2}
347  \caption[Atlantic domain defined for the CLIPPER projet]{
348    Example of Atlantic domain defined for the CLIPPER projet.
349    Initial grid is composed of 773 x 1236 horizontal points.
350    (a) the domain is split onto 9 $times$ 20 subdomains (jpni=9, jpnj=20).
351    52 subdomains are land areas.
352    (b) 52 subdomains are eliminated (white rectangles) and
353    the resulting number of processors really used during the computation is jpnij=128.}
354  \label{fig:LBC_mppini2}
355\end{figure}
356%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
357
358
359% ====================================================================
360% Unstructured open boundaries BDY
361% ====================================================================
362\section{Unstructured open boundary conditions (BDY)}
363\label{sec:LBC_bdy}
364
365%-----------------------------------------nambdy--------------------------------------------
366
367\begin{listing}
368  \nlst{nambdy}
369  \caption{\forcode{&nambdy}}
370  \label{lst:nambdy}
371\end{listing}
372%-----------------------------------------------------------------------------------------------
373%-----------------------------------------nambdy_dta--------------------------------------------
374
375\begin{listing}
376  \nlst{nambdy_dta}
377  \caption{\forcode{&nambdy_dta}}
378  \label{lst:nambdy_dta}
379\end{listing}
380%-----------------------------------------------------------------------------------------------
381
382Options are defined through the \nam{bdy}{bdy} and \nam{bdy_dta}{bdy\_dta} namelist variables.
383The BDY module is the core implementation of open boundary conditions for regional configurations on
384ocean temperature, salinity, barotropic-baroclinic velocities, ice-snow concentration, thicknesses, temperatures, salinity and melt ponds concentration and thickness.
385
386The BDY module was modelled on the OBC module (see \NEMO\ 3.4) and shares many features and
387a similar coding structure \citep{chanut_rpt05}.
388The specification of the location of the open boundary is completely flexible and
389allows any type of setup, from regular boundaries to irregular contour (it includes the possibility to set an open boundary able to follow an isobath).
390Boundary data files used with versions of \NEMO\ prior to Version 3.4 may need to be re-ordered to work with this version.
391See the section on the Input Boundary Data Files for details.
392
393%----------------------------------------------
394\subsection{Namelists}
395\label{subsec:LBC_bdy_namelist}
396
397The BDY module is activated by setting \np[=.true.]{ln_bdy}{ln\_bdy} .
398It is possible to define more than one boundary ``set'' and apply different boundary conditions to each set.
399The number of boundary sets is defined by \np{nb_bdy}{nb\_bdy}.
400Each boundary set can be either defined as a series of straight line segments directly in the namelist
401(\np[=.false.]{ln_coords_file}{ln\_coords\_file}, and a namelist block \nam{bdy_index}{bdy\_index} must be included for each set) or read in from a file (\np[=.true.]{ln_coords_file}{ln\_coords\_file}, and a ``\ifile{coordinates.bdy}'' file must be provided).
402The coordinates.bdy file is analagous to the usual \NEMO\ ``\ifile{coordinates}'' file.
403In the example above, there are two boundary sets, the first of which is defined via a file and
404the second is defined in the namelist.
405For more details of the definition of the boundary geometry see section \autoref{subsec:LBC_bdy_geometry}.
406
407For each boundary set a boundary condition has to be chosen for the barotropic solution
408(``u2d'':sea-surface height and barotropic velocities), for the baroclinic velocities (``u3d''),
409for the active tracers \footnote{The BDY module does not deal with passive tracers at this version} (``tra''), and for sea-ice (``ice'').
410For each set of variables one has to choose an algorithm and the boundary data (set resp. by \np{cn_tra}{cn\_tra} and \np{nn_tra_dta}{nn\_tra\_dta} for tracers).\\
411
412The choice of algorithm is currently as follows:
413
414\begin{description}
415\item[\forcode{'none'}:] No boundary condition applied.
416  So the solution will ``see'' the land points around the edge of the edge of the domain.
417\item[\forcode{'specified'}:] Specified boundary condition applied (only available for baroclinic velocity and tracer variables).
418\item[\forcode{'neumann'}:] Value at the boundary are duplicated (No gradient). Only available for baroclinic velocity and tracer variables.
419\item[\forcode{'frs'}:] Flow Relaxation Scheme (FRS) available for all variables.
420\item[\forcode{'Orlanski'}:] Orlanski radiation scheme (fully oblique) for barotropic, baroclinic and tracer variables.
421\item[\forcode{'Orlanski_npo'}:] Orlanski radiation scheme for barotropic, baroclinic and tracer variables.
422\item[\forcode{'flather'}:] Flather radiation scheme for the barotropic variables only.
423\end{description}
424
425The boundary data is either set to initial conditions
426(\np[=0]{nn_tra_dta}{nn\_tra\_dta}) or forced with external data from a file (\np[=1]{nn_tra_dta}{nn\_tra\_dta}).
427In case the 3d velocity data contain the total velocity (ie, baroclinic and barotropic velocity),
428the bdy code can derived baroclinic and barotropic velocities by setting \np[=.true.]{ln_full_vel}{ln\_full\_vel}
429For the barotropic solution there is also the option to use tidal harmonic forcing either by
430itself (\np[=2]{nn_dyn2d_dta}{nn\_dyn2d\_dta}) or in addition to other external data (\np[=3]{nn_dyn2d_dta}{nn\_dyn2d\_dta}).\\
431If not set to initial conditions, sea-ice salinity, temperatures and melt ponds data at the boundary can either be read in a file or defined as constant (by \np{rn_ice_sal}{rn\_ice\_sal}, \np{rn_ice_tem}{rn\_ice\_tem}, \np{rn_ice_apnd}{rn\_ice\_apnd}, \np{rn_ice_hpnd}{rn\_ice\_hpnd}). Ice age is constant and defined by \np{rn_ice_age}{rn\_ice\_age}.
432
433If external boundary data is required then the \nam{bdy_dta}{bdy\_dta} namelist must be defined.
434One \nam{bdy_dta}{bdy\_dta} namelist is required for each boundary set, adopting the same order of indexes in which the boundary sets are defined in nambdy.
435In the example given, two boundary sets have been defined. The first one is reading data file in the \nam{bdy_dta}{bdy\_dta} namelist shown above
436and the second one is using data from intial condition (no namelist block needed).
437The boundary data is read in using the fldread module,
438so the \nam{bdy_dta}{bdy\_dta} namelist is in the format required for fldread.
439For each required variable, the filename, the frequency of the files and
440the frequency of the data in the files are given.
441Also whether or not time-interpolation is required and whether the data is climatological (time-cyclic) data.
442For sea-ice salinity, temperatures and melt ponds, reading the files are skipped and constant values are used if filenames are defined as {'NOT USED'}.\\
443
444There is currently an option to vertically interpolate the open boundary data onto the native grid at run-time.
445If \np{nn_bdy_jpk}{nn\_bdy\_jpk}$<-1$, it is assumed that the lateral boundary data are already on the native grid.
446However, if \np{nn_bdy_jpk}{nn\_bdy\_jpk} is set to the number of vertical levels present in the boundary data,
447a bilinear interpolation onto the native grid will be triggered at runtime.
448For this to be successful the additional variables: $gdept$, $gdepu$, $gdepv$, $e3t$, $e3u$ and $e3v$, are required to be present in the lateral boundary files.
449These correspond to the depths and scale factors of the input data,
450the latter used to make any adjustment to the velocity fields due to differences in the total water depths between the two vertical grids.\\
451
452In the example of given namelists, two boundary sets are defined.
453The first set is defined via a file and applies FRS conditions to temperature and salinity and
454Flather conditions to the barotropic variables. No condition specified for the baroclinic velocity and sea-ice.
455External data is provided in daily files (from a large-scale model).
456Tidal harmonic forcing is also used.
457The second set is defined in a namelist.
458FRS conditions are applied on temperature and salinity and climatological data is read from initial condition files.
459
460%----------------------------------------------
461\subsection{Flow relaxation scheme}
462\label{subsec:LBC_bdy_FRS_scheme}
463
464The Flow Relaxation Scheme (FRS) \citep{davies_QJRMS76,engedahl_T95},
465applies a simple relaxation of the model fields to externally-specified values over
466a zone next to the edge of the model domain.
467Given a model prognostic variable $\Phi$
468\[
469  % \label{eq:LBC_bdy_frs1}
470  \Phi(d) = \alpha(d)\Phi_{e}(d) + (1-\alpha(d))\Phi_{m}(d)\;\;\;\;\; d=1,N
471\]
472where $\Phi_{m}$ is the model solution and $\Phi_{e}$ is the specified external field,
473$d$ gives the discrete distance from the model boundary and
474$\alpha$ is a parameter that varies from $1$ at $d=1$ to a small value at $d=N$.
475It can be shown that this scheme is equivalent to adding a relaxation term to
476the prognostic equation for $\Phi$ of the form:
477\[
478  % \label{eq:LBC_bdy_frs2}
479  -\frac{1}{\tau}\left(\Phi - \Phi_{e}\right)
480\]
481where the relaxation time scale $\tau$ is given by a function of $\alpha$ and the model time step $\Delta t$:
482\[
483  % \label{eq:LBC_bdy_frs3}
484  \tau = \frac{1-\alpha}{\alpha\,\rdt
485\]
486Thus the model solution is completely prescribed by the external conditions at the edge of the model domain and
487is relaxed towards the external conditions over the rest of the FRS zone.
488The application of a relaxation zone helps to prevent spurious reflection of
489outgoing signals from the model boundary.
490
491The function $\alpha$ is specified as a $tanh$ function:
492\[
493  % \label{eq:LBC_bdy_frs4}
494  \alpha(d) = 1 - \tanh\left(\frac{d-1}{2}\right),       \quad d=1,N
495\]
496The width of the FRS zone is specified in the namelist as \np{nn_rimwidth}{nn\_rimwidth}.
497This is typically set to a value between 8 and 10.
498
499%----------------------------------------------
500\subsection{Flather radiation scheme}
501\label{subsec:LBC_bdy_flather_scheme}
502
503The \citet{flather_JPO94} scheme is a radiation condition on the normal,
504depth-mean transport across the open boundary.
505It takes the form
506\begin{equation}
507  \label{eq:LBC_bdy_fla1}
508  U = U_{e} + \frac{c}{h}\left(\eta - \eta_{e}\right),
509\end{equation}
510where $U$ is the depth-mean velocity normal to the boundary and $\eta$ is the sea surface height,
511both from the model.
512The subscript $e$ indicates the same fields from external sources.
513The speed of external gravity waves is given by $c = \sqrt{gh}$, and $h$ is the depth of the water column.
514The depth-mean normal velocity along the edge of the model domain is set equal to
515the external depth-mean normal velocity,
516plus a correction term that allows gravity waves generated internally to exit the model boundary.
517Note that the sea-surface height gradient in \autoref{eq:LBC_bdy_fla1} is a spatial gradient across the model boundary,
518so that $\eta_{e}$ is defined on the $T$ points with $nbr=1$ and $\eta$ is defined on the $T$ points with $nbr=2$.
519$U$ and $U_{e}$ are defined on the $U$ or $V$ points with $nbr=1$, \ie\ between the two $T$ grid points.
520
521%----------------------------------------------
522\subsection{Orlanski radiation scheme}
523\label{subsec:LBC_bdy_orlanski_scheme}
524
525The Orlanski scheme is based on the algorithm described by \citep{marchesiello.mcwilliams.ea_OM01}, hereafter MMS.
526
527The adaptive Orlanski condition solves a wave plus relaxation equation at the boundary:
528\begin{equation}
529  \label{eq:LBC_wave_continuous}
530  \frac{\partial\phi}{\partial t} + c_x \frac{\partial\phi}{\partial x} + c_y \frac{\partial\phi}{\partial y} =
531  -\frac{1}{\tau}(\phi - \phi^{ext})
532\end{equation}
533
534where $\phi$ is the model field, $x$ and $y$ refer to the normal and tangential directions to the boundary respectively, and the phase
535velocities are diagnosed from the model fields as:
536
537\begin{equation}
538  \label{eq:LBC_cx}
539  c_x = -\frac{\partial\phi}{\partial t}\frac{\partial\phi / \partial x}{(\partial\phi /\partial x)^2 + (\partial\phi /\partial y)^2}
540\end{equation}
541\begin{equation}
542  \label{eq:LBC_cy}
543  c_y = -\frac{\partial\phi}{\partial t}\frac{\partial\phi / \partial y}{(\partial\phi /\partial x)^2 + (\partial\phi /\partial y)^2}
544\end{equation}
545
546(As noted by MMS, this is a circular diagnosis of the phase speeds which only makes sense on a discrete grid).
547Equation (\autoref{eq:LBC_wave_continuous}) is defined adaptively depending on the sign of the phase velocity normal to the boundary $c_x$.
548For $c_x$ outward, we have
549
550\begin{equation}
551\tau = \tau_{out}
552\end{equation}
553
554For $c_x$ inward, the radiation equation is not applied:
555
556\begin{equation}
557  \label{eq:LBC_tau_in}
558  \tau = \tau_{in}\,\,\,;\,\,\, c_x = c_y = 0
559\end{equation}
560
561Generally the relaxation time scale at inward propagation points (\np{rn_time_dmp}{rn\_time\_dmp}) is set much shorter than the time scale at outward propagation
562points (\np{rn_time_dmp_out}{rn\_time\_dmp\_out}) so that the solution is constrained more strongly by the external data at inward propagation points.
563See \autoref{subsec:LBC_bdy_relaxation} for detailed on the spatial shape of the scaling.\\
564The ``normal propagation of oblique radiation'' or NPO approximation (called \forcode{'orlanski_npo'}) involves assuming
565that $c_y$ is zero in equation (\autoref{eq:LBC_wave_continuous}), but including
566this term in the denominator of equation (\autoref{eq:LBC_cx}). Both versions of the scheme are options in BDY. Equations
567(\autoref{eq:LBC_wave_continuous}) - (\autoref{eq:LBC_tau_in}) correspond to equations (13) - (15) and (2) - (3) in MMS.\\
568
569%----------------------------------------------
570\subsection{Relaxation at the boundary}
571\label{subsec:LBC_bdy_relaxation}
572
573In addition to a specific boundary condition specified as \np{cn_tra}{cn\_tra} and \np{cn_dyn3d}{cn\_dyn3d}, relaxation on baroclinic velocities and tracers variables are available.
574It is control by the namelist parameter \np{ln_tra_dmp}{ln\_tra\_dmp} and \np{ln_dyn3d_dmp}{ln\_dyn3d\_dmp} for each boundary set.
575
576The relaxation time scale value (\np{rn_time_dmp}{rn\_time\_dmp} and \np{rn_time_dmp_out}{rn\_time\_dmp\_out}, $\tau$) are defined at the boundaries itself.
577This time scale ($\alpha$) is weighted by the distance ($d$) from the boundary over \np{nn_rimwidth}{nn\_rimwidth} cells ($N$):
578
579\[
580  \alpha = \frac{1}{\tau}(\frac{N+1-d}{N})^2,       \quad d=1,N
581\]
582
583The same scaling is applied in the Orlanski damping.
584
585%----------------------------------------------
586\subsection{Boundary geometry}
587\label{subsec:LBC_bdy_geometry}
588
589Each open boundary set is defined as a list of points.
590The information is stored in the arrays $nbi$, $nbj$, and $nbr$ in the $idx\_bdy$ structure.
591The $nbi$ and $nbj$ arrays define the local $(i,j)$ indexes of each point in the boundary zone and
592the $nbr$ array defines the discrete distance from the boundary: $nbr=1$ means that
593the boundary point is next to the edge of the model domain, while $nbr>1$ means that
594the boundary point is increasingly further away from the edge of the model domain.
595A set of $nbi$, $nbj$, and $nbr$ arrays is defined for each of the $T$, $U$ and $V$ grids.
596\autoref{fig:LBC_bdy_geom} shows an example of an irregular boundary.
597
598The boundary geometry for each set may be defined in a namelist nambdy\_index or
599by reading in a ``\ifile{coordinates.bdy}'' file.
600The nambdy\_index namelist defines a series of straight-line segments for north, east, south and west boundaries.
601One nambdy\_index namelist block is needed for each boundary condition defined by indexes.
602For the northern boundary, \texttt{nbdysegn} gives the number of segments,
603\jp{jpjnob} gives the $j$ index for each segment and \jp{jpindt} and
604\jp{jpinft} give the start and end $i$ indices for each segment with similar for the other boundaries.
605These segments define a list of $T$ grid points along the outermost row of the boundary ($nbr\,=\, 1$).
606The code deduces the $U$ and $V$ points and also the points for $nbr\,>\, 1$ if \np[>1]{nn_rimwidth}{nn\_rimwidth}.
607
608The boundary geometry may also be defined from a ``\ifile{coordinates.bdy}'' file.
609\autoref{fig:LBC_nc_header} gives an example of the header information from such a file, based on the description of geometrical setup given above.
610The file should contain the index arrays for each of the $T$, $U$ and $V$ grids.
611The arrays must be in order of increasing $nbr$.
612Note that the $nbi$, $nbj$ values in the file are global values and are converted to local values in the code.
613Typically this file will be used to generate external boundary data via interpolation and so
614will also contain the latitudes and longitudes of each point as shown.
615However, this is not necessary to run the model.
616
617For some choices of irregular boundary the model domain may contain areas of ocean which
618are not part of the computational domain.
619For example, if an open boundary is defined along an isobath, say at the shelf break,
620then the areas of ocean outside of this boundary will need to be masked out.
621This can be done by reading a mask file defined as \np{cn_mask_file}{cn\_mask\_file} in the nam\_bdy namelist.
622Only one mask file is used even if multiple boundary sets are defined.
623
624%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
625\begin{figure}[!t]
626  \centering
627  \includegraphics[width=0.66\textwidth]{Fig_LBC_bdy_geom}
628  \caption[Geometry of unstructured open boundary]{Example of geometry of unstructured open boundary}
629  \label{fig:LBC_bdy_geom}
630\end{figure}
631%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
632
633%----------------------------------------------
634\subsection{Input boundary data files}
635\label{subsec:LBC_bdy_data}
636
637The data files contain the data arrays in the order in which the points are defined in the $nbi$ and $nbj$ arrays.
638The data arrays are dimensioned on:
639a time dimension;
640$xb$ which is the index of the boundary data point in the horizontal;
641and $yb$ which is a degenerate dimension of 1 to enable the file to be read by the standard \NEMO\ I/O routines.
642The 3D fields also have a depth dimension.
643
644From Version 3.4 there are new restrictions on the order in which the boundary points are defined
645(and therefore restrictions on the order of the data in the file).
646In particular:
647
648\begin{enumerate}
649\item The data points must be in order of increasing $nbr$,
650  ie. all the $nbr=1$ points, then all the $nbr=2$ points etc.
651\item All the data for a particular boundary set must be in the same order.
652  (Prior to 3.4 it was possible to define barotropic data in a different order to
653  the data for tracers and baroclinic velocities).
654\end{enumerate}
655
656These restrictions mean that data files used with versions of the
657model prior to Version 3.4 may not work with Version 3.4 onwards.
658A \fortran\ utility {\itshape bdy\_reorder} exists in the TOOLS directory which
659will re-order the data in old BDY data files.
660
661%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
662\begin{figure}[!t]
663  \centering
664  \includegraphics[width=0.66\textwidth]{Fig_LBC_nc_header}
665  \caption[Header for a \protect\ifile{coordinates.bdy} file]{
666    Example of the header for a \protect\ifile{coordinates.bdy} file}
667  \label{fig:LBC_nc_header}
668\end{figure}
669%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
670
671%----------------------------------------------
672\subsection{Volume correction}
673\label{subsec:LBC_bdy_vol_corr}
674
675There is an option to force the total volume in the regional model to be constant.
676This is controlled  by the \np{ln_vol}{ln\_vol} parameter in the namelist.
677A value of \np[=.false.]{ln_vol}{ln\_vol} indicates that this option is not used.
678Two options to control the volume are available (\np{nn_volctl}{nn\_volctl}).
679If \np[=0]{nn_volctl}{nn\_volctl} then a correction is applied to the normal barotropic velocities around the boundary at
680each timestep to ensure that the integrated volume flow through the boundary is zero.
681If \np[=1]{nn_volctl}{nn\_volctl} then the calculation of the volume change on
682the timestep includes the change due to the freshwater flux across the surface and
683the correction velocity corrects for this as well.
684
685If more than one boundary set is used then volume correction is
686applied to all boundaries at once.
687
688%----------------------------------------------
689\subsection{Tidal harmonic forcing}
690\label{subsec:LBC_bdy_tides}
691
692%-----------------------------------------nambdy_tide--------------------------------------------
693
694\begin{listing}
695  \nlst{nambdy_tide}
696  \caption{\forcode{&nambdy_tide}}
697  \label{lst:nambdy_tide}
698\end{listing}
699%-----------------------------------------------------------------------------------------------
700
701Tidal forcing at open boundaries requires the activation of surface
702tides (i.e., in \nam{_tide}{\_tide}, \np{ln_tide}{ln\_tide} needs to be set to
703\forcode{.true.} and the required constituents need to be activated by
704including their names in the \np{clname}{clname} array; see
705\autoref{sec:SBC_tide}). Specific options related to the reading in of
706the complex harmonic amplitudes of elevation (SSH) and barotropic
707velocity (u,v) at open boundaries are defined through the
708\nam{bdy_tide}{bdy\_tide} namelist parameters.\\
709
710The tidal harmonic data at open boundaries can be specified in two
711different ways, either on a two-dimensional grid covering the entire
712model domain or along open boundary segments; these two variants can
713be selected by setting \np{ln_bdytide_2ddta }{ln\_bdytide\_2ddta } to \forcode{.true.} or
714\forcode{.false.}, respectively. In either case, the real and
715imaginary parts of SSH and the two barotropic velocity components for
716each activated tidal constituent \textit{tcname} have to be provided
717separately: when two-dimensional data is used, variables
718\textit{tcname\_z1} and \textit{tcname\_z2} for real and imaginary SSH,
719respectively, are expected in input file \np{filtide}{filtide} with suffix
720\ifile{\_grid\_T}, variables \textit{tcname\_u1} and
721\textit{tcname\_u2} for real and imaginary u, respectively, are
722expected in input file \np{filtide}{filtide} with suffix \ifile{\_grid\_U}, and
723\textit{tcname\_v1} and \textit{tcname\_v2} for real and imaginary v,
724respectively, are expected in input file \np{filtide}{filtide} with suffix
725\ifile{\_grid\_V}; when data along open boundary segments is used,
726variables \textit{z1} and \textit{z2} (real and imaginary part of SSH)
727are expected to be available from file \np{filtide}{filtide} with suffix
728\ifile{tcname\_grid\_T}, variables \textit{u1} and \textit{u2} (real
729and imaginary part of u) are expected to be available from file
730\np{filtide}{filtide} with suffix \ifile{tcname\_grid\_U}, and variables
731\textit{v1} and \textit{v2} (real and imaginary part of v) are
732expected to be available from file \np{filtide}{filtide} with suffix
733\ifile{tcname\_grid\_V}. If \np{ln_bdytide_conj}{ln\_bdytide\_conj} is set to
734\forcode{.true.}, the data is expected to be in complex conjugate
735form.
736
737Note that the barotropic velocity components are assumed to be defined
738on the native model grid and should be rotated accordingly when they
739are converted from their definition on a different source grid. To do
740so, the u, v amplitudes and phases can be converted into tidal
741ellipses, the grid rotation added to the ellipse inclination, and then
742converted back (care should be taken regarding conventions of the
743direction of rotation). %, e.g. anticlockwise or clockwise.
744
745\onlyinsubfile{\bibliography{../main/bibliography}}
746
747\onlyinsubfile{\printindex}
748
749\end{document}
Note: See TracBrowser for help on using the repository browser.