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

Last change on this file since 14433 was 14433, checked in by smasson, 3 years ago

trunk: merge dev_r14312_MPI_Interface into the trunk, #2598

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