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_MISC.tex in trunk/DOC/BETA/Chapters – NEMO

source: trunk/DOC/BETA/Chapters/Chap_MISC.tex @ 817

Last change on this file since 817 was 817, checked in by gm, 16 years ago

trunk - update including Steven correction of the first 5 chapters (until DYN) and activation of Appendix A & B

  • Property svn:executable set to *
File size: 37.3 KB
Line 
1% ================================================================
2% Chapter Ñ Miscellaneous Topics
3% ================================================================
4\chapter{Miscellaneous Topics (xxx)}
5\label{MISC}
6\minitoc
7
8% ================================================================
9% Representation of Unresolved Straits
10% ================================================================
11\section{Representation of Unresolved Straits}
12\label{MISC_strait}
13
14% In climate modeling, it is often necessary to allow water masses that are separated by land to exchange properties. This situation arises in models when the grid mesh is too coarse to resolve narrow passageways that in reality provide crucial connections between water masses. For example, coarse grid spacing typically closes off the Mediterranean from the Atlantic at the Straits of Gibraltar. In this case, it is important for climate models to include the effects of salty water entering the Atlantic from the Mediterranean. Likewise, it is important for the Mediterranean to replenish its supply of water from the Atlantic to balance the net evaporation occurring over the Mediterranean region.
15% also same problem as soon as important straits are not properly resolve by the mesh. For example in ORCA 1/4\r{}, this occors in several straits of the Indonesian archipelagos (Ombai, Lombok...).
16% We describe here the three methods that can be used in NEMO to handle such unproperly resolved straits.
17%The communication consists of mixing tracers and mass/volume between non-adjacent water columns. Momentum is not mixed. The scheme conserves total tracer content, and total volume (the latter in $z*$- or $s*$-coordinate), and maintains compatibility between the tracer and mass/volume budgets. 
18
19% Note: such changes are so specific to a given configuration that no attempt have been made to set them in a generic way. Nevertheless, example of how they can be set up is given in the ORCA2 configuration (\key{ORCA_R2}).
20
21% -------------------------------------------------------------------------------------------------------------
22%       Hand made geometry changes
23% -------------------------------------------------------------------------------------------------------------
24\subsection{Hand made geometry changes}
25\label{MISC_strait_hand}
26
27$\bullet$ reduced scale factor, also called partially open face (Hallberg, personnal communication 2006)
28%also called partially open cell  or partial closed cells
29$\bullet$ increase of the viscous boundary layer by local increase of the fmask value at the coast
30
31\colorbox{yellow}{Add a short description of scale factor changes staff and fmask increase}
32
33
34%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
35\begin{figure}[!tbp] \label{Fig_MISC_strait_hand}  \begin{center}
36\includegraphics[width=0.80\textwidth]{./Figures/Fig_Gibraltar.pdf}
37\includegraphics[width=0.80\textwidth]{./Figures/Fig_Gibraltar2.pdf}
38\caption {Example of the Gibraltar strait defined in a 1\r{} x 1\r{} mesh. \textit{Top}: using partially open cells. The meridional scale factor at $V$-point is reduced on both sides of the strait to account for the real width of the strait (about 20 km). Note that the scale factors of the strait $T$-point remains unchanged. \textit{Bottom}: using viscous boundary layers. The four fmask along the strait coastlines are set to a value larger than 4, $i.e.$ "strong" no-slip case (see Fig.\ref{Fig_LBC_shlat}) creating a large viscous boundary layer that allows a reduced transport through the strait.}
39\end{center}   \end{figure}
40%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
41
42% -------------------------------------------------------------------------------------------------------------
43% Cross Land Advection
44% -------------------------------------------------------------------------------------------------------------
45\subsection{Cross Land Advection (\textit{tracla} module)}
46\label{MISC_strait_cla}
47
48%--------------------------------------------namcro--------------------------------------------------------
49\namdisplay{namcro} 
50%--------------------------------------------------------------------------------------------------------------
51
52\colorbox{yellow}{Add a short description of CLA staff here or in lateral boundary condition chapter?}
53
54% ================================================================
55% Closed seas
56% ================================================================
57\section{Closed seas}
58\label{MISC_closea}
59
60
61% ================================================================
62% Sub-Domain Functionality (\textit{nizoom, njzoom}, namelist parameters)
63% ================================================================
64\section{Sub-Domain Functionality (\jp{jpizoom}, \jp{jpjzoom})}
65\label{MISC_zoom}
66
67The sub-domain functionality, also improperly called zoom option (improperly because it is not associated with a change in model resolution) is a quite simple function that allows to
68perform a simulation over a sub-domain of an already defined configuration
69(i.e. without defining a new set of mesh, initial state and forcings). This
70option can be useful for testing the user setting of surface boundary
71conditions, or the initial ocean state of a huge ocean model configuration
72while having a small central memory requirement. It can also be used to
73easily test specific physics in a sub-domain (for example, test of the
74coupling between sea-ice and ocean model over the Arctic or Antarctic ocean
75as they are set in the global ocean version of OPA \citep{Madec1996}.
76In standard, this option does not include any specific treatment for ocean
77boundaries of the sub-domain: they are considered as artificial vertical
78walls. Nevertheless, it is quite easy to add a restoring term toward a
79climatology in the vicinity of those boundaries (see \S\ref{TRA_dmp}).
80
81In order to easily define a sub-domain over which the computation can be
82performed, the dimension of all input arrays (ocean mesh, bathymetry,
83forcing, initial state, ...) are defined as \jp{jpidta}, \jp{jpjdta} and \jp{jpkdta} (\mdl{par\_oce} module), while the
84computational domain is defined through \jp{jpiglo}, \jp{jpjglo} and \jp{jpk} (\mdl{par\_oce} module). When running the model
85over the whole configuration, the user set \jp{jpiglo}=\jp{jpidta} \jp{jpjglo}=\jp{jpjdta }and \jp{jpk}=\jp{jpkdta}. When running the model
86over a sub-domain, the user have to provide the size of the sub-domain,
87(\jp{jpiglo}, \jp{jpjglo}, \jp{jpkglo}), and the indices of the south western corner as \jp{jpizoom} and \jp{jpjzoom} in the \mdl{par\_oce} module (Fig.~\ref{Fig_LBC_zoom}).
88
89Note that a third set of dimension exist, \jp{jpi}, \jp{jpj} and \jp{jpk} which is actually used to
90perform the computation. It is set by default to \jp{jpi}=\jp{jpjglo} and \jp{jpj}=\jp{jpjglo}, except for massively
91parallel computing where the computational domain is laid out on local
92processor memories following a 2D horizontal splitting (see {\S}IV.2-c)
93
94%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
95\begin{figure}[!ht] \label{Fig_LBC_zoom}  \begin{center}
96\includegraphics[width=0.90\textwidth]{./Figures/Fig_LBC_zoom.pdf}
97\caption {position of a model domain compared to the data input domain when the zoom functionality is used.}
98\end{center}   \end{figure}
99%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
100
101
102% ================================================================
103% 1D model functionality
104% ================================================================
105\section{Water column model: 1D model (\key{cfg\_1d})}
106\label{MISC_1D}
107
108The 1D model is a stand alone water column based on the 3D NEMO system. It can be applied to the ocean alone or to the ocean-ice system and can include passive tracers or a biogeochemical model. It is set up by defining the \key{cfg\_1d} CPP key. This 1D model is a very useful tool  \textit{(a)} to learn about the physics and numerical treatment of vertical mixing processes ; \textit{(b)} to investigate suitable parameterizations of unresolved turbulence (wind steering, langmuir circulation, skin layers) ; \textit{(c)} to compare the behaviour of different mixing vertical scheme  ; \textit{(d)} to perform sensitivity study to the vertical diffusion on a particular point of the ocean global domain ; \textit{(d)} to access to specific diagnostics, aside from the standard model variables,  because of having small in core memory requirement.
109
110The methodology is based on the use of the zoom functionality (see \S\ref{MISC_zoom}), and the addition of some specific routines. There is no need of defining a new set of mesh, bathymetry, initial state and forcing, as the 1D model will use those of the configuration it is a zoom of.
111
112 
113
114% ================================================================
115% Accelerating the Convergence
116% ================================================================
117\section{Accelerating the Convergence (\np{nn\_acc} = 1)}
118\label{MISC_acc}
119%--------------------------------------------namdom-------------------------------------------------------
120\namdisplay{namdom} 
121%--------------------------------------------------------------------------------------------------------------
122
123Searching an equilibrium state with an ocean model requires very long time
124integration (a few thousand years for a global model). Due to the size of
125the time step required for numerical stability consideration (less than a
126few hours), this is usually requires a large elapse time. In order overcome
127this problem, \citet{Bryan1984} introduces a technique that allows to accelerate
128the spin up to the equilibrium. It consists in using a larger time step in
129the thermodynamic evolution equations than in the dynamic evolution
130equations. It does not affect the equilibrium solution but modifies the
131trajectory to reach it.
132
133The acceleration of convergence is used when \np{nn\_acc}=1. In that case, $\Delta t=rdt$ is
134the time step of dynamics while $\widetilde{\Delta t}=rdttra$ is the tracer time-step. Both are settled from \np{rdt} and \np{rdttra}  namelist parameters. The set of prognostic equations to solve becomes:
135\begin{equation} \label{Eq_acc}
136\begin{split}
137\frac{\partial \textbf{U}_h }{\partial t} 
138   &\equiv \frac{\textbf{U}_h ^{t+1}-\textbf{U}_h^{t-1} }{2\Delta t} = \ldots \\ 
139\frac{\partial T}{\partial t} &\equiv \frac{T^{t+1}-T^{t-1}}{2 \widetilde{\Delta t}} = \ldots \\ 
140\frac{\partial S}{\partial t} &\equiv \frac{S^{t+1} -S^{t-1}}{2 \widetilde{\Delta t}} = \ldots \\ 
141\end{split}
142\end{equation}
143
144\citet{Bryan1984} has analysed the consequences of this distorted physics. Free
145waves have a slower phase speed, their meridional structure is slightly
146modified, and the growth rate of baroclinically unstable waves is reduced
147but there is a wider range of instability. This technique is efficient for
148searching an equilibrium state in coarse resolution models. However its
149application is not suitable for many oceanic problems: it cannot be used for
150transient or time evolving problems (in particular, it is very questionable
151to keep this technique when using a seasonal cycle in the forcing fields),
152and it cannot be used in high-resolution models where baroclinically
153unstable processes are important. Moreover, the vertical variation of
154$\Delta \tilde {t}$ implies that the heat and salt contents are no more
155conserved due to the vertical coupling of the ocean level through both
156advection and diffusion.
157
158
159% ================================================================
160% Model optimisation, Control Print and Benchmark
161% ================================================================
162\section{Model optimisation, Control Print and Benchmark}
163\label{MISC_opt}
164%--------------------------------------------namdom-------------------------------------------------------
165\namdisplay{nam_ctl} 
166%--------------------------------------------------------------------------------------------------------------
167
168Three points to be described here:
169
170$\bullet$ Vector and memory optimisation:
171
172 \key{vectopt\_loop} enable the internal loop collapse, a very efficient way to increase the length of vector and thus speed up the model on vector computers.
173 
174 Add here also one word on NPROMA technique that has been found useless, since compiler have made significant progress during the last decade.
175 
176 Add also one word on NEC specific optimisation (Novercheck option for example)
177
178 \key{vectopt\_memory} has been introduced in order to reduce the memory requirement of the model. This is obviously done by incresing the CPU time requirement, as it suppress intermediate computation saved in in-core memory. This possibility have not been intensively used. In fact up to now, it only concern the TKE physics, in which,  when \key{vectopt\_memory} is defined, the coefficient used for horizontal smoothing of $A_v^T$ and $A_v^m$ are no more computed once for all. This reduces the memory requirement by three 2D arrays.
179 
180$\bullet$ Control print: describe here 4 things:
181
1821- \np{ln\_ctl} : compute and print the inner domain averaged trends in all TRA, DYN LDF and ZDF modules. Very useful to detect the origin of an undesired change in model results.
183
1842- also \np{ln\_ctl} but using the nictl. njctl. namelist parameters to check the origin of differences between mono and multi processor
185
1863- \key{esopa} (to be rename key\_nemo) : also a option of model management. When defined, this key force the activation of all options and CPP keys. For example, all the tracer and momentum advection scheme are called ! There is therefore no physical meaning associated with model results. In fact, this option allows both the compilator and the model run to go through all the Fortran lines of the model. This allows to check is there is obvious compilation or running bugs for CPP options, and running bugs for namelist options.
187
1885- last digit comparison (\np{nbit\_cmp}). In MPP simulation, the computation of sum of the whole domain is performed as the sum over all processors of the sum of the inner domain of each processor. This double sum nevr give exactly the same result as a single sum over the whole domain, due to truncature differences. The "bit comparison" option has been introduced in order to be able to check that mono-processor and multi-processor give exactly the same results.
189
190
191$\bullet$  Benchmark (\np{nbench}). This option, defines a benchmark run based on GYRE configuration in which the resolution remains the same whatever the domain size is. This allows to run very large model domain by just changing the domain size (\jp{jpiglo}, \jp{jpjglo}) without adjusting neither the time-step nor the physical parametrisations.
192
193
194% ================================================================
195% Elliptic solvers (SOL)
196% ================================================================
197\section{Elliptic solvers (SOL directory)}
198\label{MISC_sol}
199%--------------------------------------------namdom-------------------------------------------------------
200\namdisplay{namsol} 
201%--------------------------------------------------------------------------------------------------------------
202
203The computation of the surface pressure gradient with a rigid lid assumption
204requires to compute $\partial_t \psi$, the time evolution of the
205barotropic streamfunction. $\partial_t \psi$ is solution of an elliptic
206equation (I.2.4) for which two solvers are available, a
207Successive-Over-Relaxation (SOR) or a preconditioned conjugate gradient
208(PCG) \citep{Madec1988, Madec1990}. The PCG is a very efficient
209method for solving elliptic equations on vector computers. It is a fast and
210rather easy to use method, which is an attractive feature for a large number
211of ocean situations (variable bottom topography, complex coastal geometry,
212variable grid spacing, islands, open or cyclic boundaries, etc ...). It does
213not require the search of an optimal parameter as in the SOR method.
214Nevertheless, the SOR has been kept because it is a linear solver, a very
215useful property when using the adjoint model of OPA.
216
217The surface pressure gradient is computed in \mdl{dynspg}. The
218default option is the use of PCG or SOR
219depending on \np{nsolv} (namelist parameter).
220At each time step the time derivative of the barotropic streamfunction is
221the solution of (II.2.3). Introducing the following coefficients:
222
223\begin{equation} 
224\begin{aligned}
225&C_{i,j}^{NS} &&= \frac{e_{2v}(i,j)}{\left( H_v (i,j) e_{1v} (i,j)\right)}\\
226&C_{i,j}^{EW} &&= \frac{e_{1u}(i,j)}{\left( H_u (i,j) e_{2u} (i,j)\right)}\\
227&B_{i,j} &&= \delta_i \left( e_{2v}M_v \right) - \delta_j \left( e_{1u}M_u \right)\\
228\end{aligned}
229\end{equation}
230
231the five-point finite difference equivalent equation (II.2.3) can be rewritten as:
232
233\begin{multline} \label{Eq_solmat}
234C_{i+1,j}^{NS} {   \left\frac{\partial \psi}{\partial t } \right)    }_{i+1,j} + \;
235C_{i,j+1}^{EW}{   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j+1} + \;
236C_{i,j}    ^{NS} {   \left\frac{\partial \psi}{\partial t } \right)    }_{i-1,j} + \;
237C_{i,j}    ^{EW}{   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j-1}\\
238-\left(C_{i+1,j}^{NS} + C_{i,j+1}^{EW} + C_{i,j}^{NS} + C_{i,j}^{EW} \right)   {   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j}  =  B_{i,j}
239\end{multline}
240\eqref{Eq_solmat} is a linear symmetric system of equations. All the elements of the
241corresponding matrix \textbf{A} vanish except those of five diagonals. With
242the natural ordering of the grid points (i.e. from west to east and from
243south to north), the structure of \textbf{A} is block-tridiagonal with
244tridiagonal or diagonal blocks. \textbf{A} is a positive-definite symmetric
245matrix of size $(jpi \cdot jpj)^2$, and \textbf{B}, the right hand side of
246\eqref{Eq_solmat}, is a vector.
247
248% -------------------------------------------------------------------------------------------------------------
249%       Successive Over Relaxation
250% -------------------------------------------------------------------------------------------------------------
251\subsection{Successive Over Relaxation \np{nsolv}=2}
252\label{MISC_solsor}
253
254Let us introduce the four cardinal coefficients: $A_{i,j}^S = C_{i,j}^{NS}/D_{i,j}\,$,
255$A_{i,j}^W = C_{i,j}^{EW}/D_{i,j}\,$, $A_{i,j}^E = C_{i,j+1}^{EW}/D_{i,j}\,$ and $A_{i,j}^N = C_{i+1,j}^{NS}/D_{i,j}\,$, and define
256$\tilde B_{i,j} = B_{i,j}/D_{i,j}\,$, where $D_{i,j} = C_{i,j}^{NS}+ C_{i+1,j}^{NS} + C_{i,j}^{EW} + C_{i,j+1}^{EW} $ (i.e. the diagonal of
257\textbf{A}). (VII.5.1) can be rewritten as:
258
259\begin{multline} 
260    A_{i,j}^{N}  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i+1,j   } 
261+\,A_{i,j}^{E}  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i    ,j+1}       \\
262+\,A_{i,j}^{S}  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i-1 ,j    } 
263+\,A_{i,j}^{W} {   \left\frac{\partial \psi}{\partial t } \right)    }_{i    ,j-1} 
264               -  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j} = \tilde B_{i,j}
265\end{multline}
266
267The SOR method used is an iterative method. Its algorithm can be summarised
268as follows [see \citet{Haltiner1980} for further discussion]:
269
270initialisation (evaluate a first guess from former time step computations)
271\begin{equation}
272\left\frac{\partial \psi}{\partial t } \right)_{i,j}^0 = 2{\left\frac{\partial \psi}{\partial t } \right)_{i,j}^t} - {\left\frac{\partial \psi}{\partial t } \right)_{i,j}^{t-1}}
273\end{equation}
274iteration $n,$ from $n=0 $until convergence, do :
275\begin{multline} 
276R_{i,j}^n
277= A_{i,j}^{N}  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i+1,j}^n
278+\,A_{i,j}^{E}  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j+1} ^n     \\
279+\,A_{i,j}^{S}  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i-1,j} ^{n+1}
280+\,A_{i,j}^{W} {   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j-1} ^{n+1} 
281                   -  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j}^n - \tilde B_{i,j}
282\end{multline}
283\begin{equation} 
284     {   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j} ^{n+1}
285  = {   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j} ^{n}
286  + \omega \;R_{i,j}^n
287\end{equation}
288where \textit{$\omega $ }satisfies $1\leq \omega \leq 2$. An optimal value exists for \textit{$\omega $ }which
289accelerates significantly the convergence, but it has to be adjusted
290empirically for each model domain, except for an uniform grid where an
291analytical expression for \textit{$\omega $ }can be found \citep{Richtmyer1967}. This
292parameter is defined as \textit{sor}, a \textbf{namelist} parameter. The convergence test is of the form:
293\begin{equation}
294\delta = \frac{\sum\limits_{i,j}{R_{i,j}^n}{R_{i,j}^n}}{\sum\limits_{i,j}{ \tilde B_{i,j}^n}{\tilde B_{i,j}^n}} \leq \epsilon
295\end{equation}
296where $\epsilon $ is the absolute precision that is required. It is highly recommended
297to use a $\epsilon $ smaller or equal to $10^{-2}$ as larger values may leads
298to numerically induced basin scale barotropic oscillations, and to use a two
299or three order of magnitude smaller value in eddy resolving configuration.
300The precision of the solver is not only a numerical parameter, but
301influences the physics. Indeed, the zero change of kinetic energy due to the
302work of surface pressure forces in rigid-lid approximation is only achieved
303at the precision demanded on the solver ({\S}~C.1-e). The precision is
304specified by setting \textit{eps} (\textbf{namelist parameter}). In addition, two other tests are used to stop the iterative
305algorithm. They concern the number of iterations and the module of the right
306hand side. If the former exceeds a specified value, \textit{nmax} (\textbf{namelist parameter}), or the latter is greater than
307$10^{15}$, the whole model computation is stopped while the last
308computed time step fields are saved in the standard output file. In both
309cases, this usually indicates that there is something wrong in the model
310configuration (error in the mesh, the initial state, the input forcing, or
311the magnitude of the time step or of the mixing coefficients). A typical
312value of $nmax$ is a few hundred for $\epsilon = 10^{-2}$, increasing to a few
313thousand for $\epsilon = 10^{-12}$.
314
315The vectorization of the SOR algorithm is not straightforward. (VII.5.4)
316contains two linear recurrences on $i$ and $j$. This inhibits the vectorisation
317({\S}~IV.2-a). Therefore (VII.5.4a) has been rewritten as:
318
319\begin{multline} 
320R_{i,j}^n
321= A_{i,j}^{N}  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i+1,j}^n
322+\,A_{i,j}^{E}  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j+1} ^n     \\
323+\,A_{i,j}^{S}  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i-1,j} ^{n}
324+\,A_{i,j}^{W} {   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j-1} ^{n} 
325                   -  {   \left\frac{\partial \psi}{\partial t } \right)    }_{i,j}^n - \tilde B_{i,j}
326\end{multline}
327
328\begin{equation}
329R_{i,j}^n = R_{i,j}^n - \omega \;A_{i,j}^{S}\; R_{i,j-1}^n
330\end{equation}
331
332\begin{equation}
333R_{i,j}^n = R_{i,j}^n - \omega \;A_{i,j}^{W}\; R_{i-1,j}^n
334\end{equation}
335
336If the three equations in (VII.5.6) are solved inside the same do-loop,
337(VII.5.4a) and (VII.5.6) are strictly equivalent. In the model they are
338solved successively over the whole domain. The convergence is slower but
339(VII.5.6a) and (VII.5.6b) are vector loops on $i$-index (the inner loop) and
340(VII.5.6c) is adapted to Cray vector computers by using a routine from the
341Cray library (namely the FOLR routine) to solve the first-order linear
342recurrence. The SOR method is very flexible and can be used under a wide
343range of conditions, including irregular boundaries, interior boundary
344points, etc. Proofs of convergence, etc. may be found in the standard
345numerical methods texts for partial equations.
346
347% -------------------------------------------------------------------------------------------------------------
348%       Preconditioned Conjugate Gradient
349% -------------------------------------------------------------------------------------------------------------
350\subsection{Preconditioned Conjugate Gradient}
351\label{MISC_solpcg}
352
353\begin{flushright}
354(\textit{nbsfs=1}, \textbf{namelist parameter})
355\end{flushright}
356
357\textbf{A} is a definite positive symmetric matrix, thus solving the linear
358system (VII.5.1) is equivalent to the minimisation of a quadratic
359functional:
360\begin{equation*}
361\textbf{Ax} = \textbf{b} \leftrightarrow \textbf{x} =\text{inf}_{y} \,\phi (\textbf{y})
362\quad , \qquad
363\phi (\textbf{y}) = 1/2 \langle \textbf{Ay},\textbf{y}\rangle - \langle \textbf{b},\textbf{y} \rangle 
364\end{equation*}
365where $\langle , \rangle$ is the canonical dot product. The idea of the
366conjugate gradient method is to search the solution in the following
367iterative way: assuming that $\textbf{x}^n$ is obtained, $\textbf{x}^{n+1}$ is searched under the form $\textbf {x}^{n+1}={\textbf {x}}^n+\alpha^n{\textbf {d}}^n$ which satisfies:
368\begin{equation*}
369{\textbf{ x}}^{n+1}=\text{inf} _{{\textbf{ y}}={\textbf{ x}}^n+\alpha \,{\textbf{ d}}^n} \,\phi ({\textbf{ y}})\;\;\Leftrightarrow \;\;\frac{d\phi }{d\alpha}=0
370\end{equation*}
371and expressing $\phi (\textbf{y})$ as a function of \textit{$\alpha $}, we obtain the value that minimises the functional:
372\begin{equation*}
373\alpha ^n = \langle{ \textbf{r}^n , \textbf{r}^n} \rangle  / \langle {\textbf{ A d}^n, \textbf{d}^n} \rangle
374\end{equation*}
375where $\textbf{r}^n = \textbf{b}-\textbf{A x}^n = \textbf{A} (\textbf{x}-\textbf{x}^n)$ is the error at rank $n$. The choice of the descent vector $\textbf{d}^n$ depends on the error: $\textbf{d}^n = \textbf{r}^n + \beta^n \,\textbf{d}^{n-1}$. $\beta ^n$ is searched such that the descent vectors form an orthogonal base for the dot product linked to \textbf{A}. Expressing the condition
376$\langle \textbf{A d}^n, \textbf{d}^{n-1} \rangle = 0$ the value of $\beta ^n$ is found:
377 $\beta ^n = \langle{ \textbf{r}^n , \textbf{r}^n} \rangle  / \langle {\textbf{r}^{n-1}, \textbf{r}^{n-1}} \rangle$. As a result, the errors $ \textbf{r}^n$ form an orthogonal base
378for the canonic dot product while the descent vectors $\textbf{d}^n$ form
379an orthogonal base for the dot product linked to \textbf{A}. The resulting
380algorithm is thus the following one:
381
382initialisation :
383
384
385\begin{equation*} 
386\textbf{x}^0 = \left\frac{\partial \psi}{\partial t } \right)_{i,j}^0 = 2{\left\frac{\partial \psi}{\partial t } \right)_{i,j}^t} - {\left\frac{\partial \psi}{\partial t } \right)_{i,j}^{t-1}}
387, \text{the initial guess }
388\end{equation*}
389
390\begin{equation*}
391\textbf{r}^0 = \textbf{d}^0 = \textbf{b} - \textbf{A x}^0
392\end{equation*}
393\begin{equation*}
394\gamma_0 = \langle{ \textbf{r}^0 , \textbf{r}^0} \rangle
395\end{equation*}
396iteration $n,$ from $n=0$ until convergence, do :
397
398\begin{equation} 
399\begin{split}
400\text{z}^n& = \textbf{A d}^n \\
401\alpha_n &= \gamma_\langle{ \textbf{z}^n , \textbf{d}^n} \rangle \\
402\textbf{x}^{n+1} &= \textbf{x}^n + \alpha_n \,\textbf{d}^n \\
403\textbf{r}^{n+1} &= \textbf{r}^n - \alpha_n \,\textbf{z}^n \\
404\gamma_{n+1} &= \langle{ \textbf{r}^{n+1} , \textbf{r}^{n+1}} \rangle \\
405\beta_{n+1} &= \gamma_{n+1}/\gamma_{n}  \\
406\textbf{d}^{n+1} &= \textbf{r}^{n+1} + \beta_{n+1}\; \textbf{d}^{n}\\
407\end{split}
408\end{equation}
409
410
411The convergence test is:
412
413\begin{equation}
414\delta = \gamma_{n}\; / \langle{ \textbf{b} , \textbf{b}} \rangle \leq \epsilon
415\end{equation}
416where $\epsilon $ is the absolute precision that is required. As for the SOR algorithm,
417both the PCG algorithm and the whole model computation are stopped when the
418number of iteration, $nmax$, or the module of the right hand side exceeds a
419specified value (see {\S}~VII.5-a for further discussion). The precision and
420the maximum number of iteration are specified by setting $eps$ and $nmax$ (\textbf{namelist parameters}).
421
422It can be demonstrated that the algorithm is optimal, provides the exact
423solution in a number of iterations equal to the size of the matrix, and that
424the convergence rate is all the more fast as the matrix is closed to
425identity (i.e. the eigen values are closed to 1). Therefore, it is more
426efficient to solve a better conditioned system which has the same solution.
427For that purpose, we introduce a preconditioning matrix \textbf{Q
428}which is an approximation of \textbf{A} but much easier to invert
429than \textbf{A} and solve the system:
430\begin{equation} 
431\textbf{Q}^{-1} \textbf{A x} = \textbf{Q}^{-1} \textbf{b}
432\end{equation}
433
434The same algorithm can be used to solve (VII.5.7) if instead of the
435canonical dot product the following one is used: ${\langle{ \textbf{a} , \textbf{b}} \rangle}_Q = \langle{ \textbf{a} , \textbf{Q b}} \rangle$, and if $\textbf{\~{b}} = \textbf{Q}^{-1}\;\textbf{b}$ and $\textbf{\~{A}} = \textbf{Q}^{-1}\;\textbf{A}$ are substituted to \textbf{b} and \textbf{A} \citep{Madec1988}. In OPA, \textbf{Q} is chosen as the diagonal
436of\textbf{ A}, i.e. the simplest form for \textbf{Q} so that it can be
437easily inverted. In this case, the discrete formulation of (VII.5.8) is in
438fact given by (VII.5.2) and thus the matrix and right hand side are computed
439independently from the solver used.
440
441% -------------------------------------------------------------------------------------------------------------
442%       FETI
443% -------------------------------------------------------------------------------------------------------------
444\subsection{FETI}
445\label{MISC_solfeti}
446
447FETI is a powerfull solver that was developed by Marc Guyon (ref !!!).  It as been just converted from Fortan 77 to 90, but never successfully tested after that. Since then, nobody has found enough time to further investigate the implmenntationof FETI and debug it.
448
449Its main advantaged is to save a lot of CPU time compared to SOR or PCG algorithm. Nevertheless, its main drawbacks is that the solution is depends on the domain decomposition chosen. Using a different number of processors, the solution is the same at the precision required, but not the same at the computer precision. This make it hard to debug. 
450
451% -------------------------------------------------------------------------------------------------------------
452%       Boundary Conditions --- Islands
453% -------------------------------------------------------------------------------------------------------------
454\subsection{Boundary Conditions --- Islands (\key{islands})}
455\label{MISC_solisl}
456
457The boundary condition used for both solvers is that the time derivative of
458the barotropic streamfunction is zero along all the coastlines. When islands
459are present in the model domain, additional computations must be done to
460determine the barotropic streamfunction with the correct boundary
461conditions. This is detailed below.
462
463The model does not recognise itself the islands which must be defined using
464bathymetry information, i.e. $mbathy$ array, equals $-1$ over the first island, $-2$ over
465the second, ... , $-N$ over the $N^{th}$ island (see {\S}~VII.2-b). The model
466determines the position of island grid-points and defines a closed contour
467around each island which will be used to compute the circulation around each
468island. The closed contour is formed of the ocean grid-points which are the
469closest to the island.
470
471First, the island barotropic streamfunctions $\psi_n$ are computed
472using the PCG (they are solutions of (VII.5.1) with the right-hand side
473equals to zero and with $\psi_n = 1$ along the island $n$ and $\psi_n = 0$ along the other coastlines) (Note that specifying $1$ as boundary
474condition on an island for $\psi$ is equivalent to define a
475specific right hand side for (VII.5.1)~). The precision of this computation
476can be very high since it is done once. The absolute precision, $epsisl$, and the
477maximum number of iteration, $nmisl$, are the \textbf{namelist parameters} used for that
478computation. Their typical values are $epsisl = 10^{-10}$ and $nmisl = 4000$. Then the island matrix A is computed from (I.2.8) and reversed. At
479each time step, $\psi_0$, the solution of (I.2.4) with $\psi_0 = 0$ along all coastlines, is computed using either SOR or PCG. It has to
480be noted that the first guess of this computation is defined as in (VII.5.3)
481except that $\partial_t \psi_0$ is used, not $\partial_t \psi$. Indeed we are
482computing $\partial_t \psi_0$ which is usually far different from $\partial_t \psi$. Then, it is easy to find the time evolution of the barotropic
483streamfunction on each island and to deduce $\partial_t \psi$ using (I.2.9)
484in order to compute the surface pressure gradient. Note that the value of
485the barotropic streamfunction itself is also computed as the time
486integration of $\partial_t \psi$ for further diagnostics.
487
488% ================================================================
489% Diagnostics
490% ================================================================
491\section{Diagnostics }
492\label{MISC_diag}
493
494% -------------------------------------------------------------------------------------------------------------
495%       Standard Model Output
496% -------------------------------------------------------------------------------------------------------------
497\subsection{Standard Model Output (default option or \key{dimg})}
498\label{MISC_iom}
499
500%to be updated with Seb documentation on the IO
501\amtcomment{ 
502The model outputs are of three types: the restart file, the output listing,
503and the output file(s). The restart file is used internally by the code when
504the user wants to start the model with initial conditions defined by a
505previous simulation. It contains all the information that is necessary not
506to introduce changes in the model results (even at the computer precision)
507between a run performed with several restarts and the same run performed in
508one time. It has to be noticed that this requires that the restart file
509contains two consecutive time steps for all the prognostic variables, and
510that it is save in the same binary format as the one used by the computer to
511calculate (in particular, 32 bits binary IEEE format for this file must not
512be used). The output listing and file(s) are defined but should be checked
513and eventually adapted to the user's needs. The output listing is stored in
514the $ocean.output$ file. The information are printed all the way through the code on the
515logical unit $numout$. To locate these prints, use the UNIX command "$grep -i numout^*$" in the source code directory.
516
517In the standard configuration, the user will find the model results in two
518output files for every time-step where output is demanded: a \textbf{VO} 
519file containing all the three dimensional fields in logical unit $numwvo$, and a
520\textbf{SO} file containing all the two dimensional (horizontal) fields in
521logical unit $numwso$. These outputs are defined in the $diawri.F$ routine. The standard and available on-line diagnostics are described in {\S}III-12-c.
522
523The default output is 32 bits binary IEEE format, compatible with the
524Vairmer software (see the Climate Modelling and global Change team WEB
525server at CERFACS: http://www.cerfacs.fr). The model's reference directory
526also contains a visualisation tool based on \textbf{NCAR Graphics
527}(http://ngwww.ucar.edu). If a user has access to the NCAR software, he or
528she can copy the \textbf{LODMODEL/UTILS/OPADRA} directory from the reference
529and, following the \textbf{README}, create the graphic outputs from the
530model's results.
531}
532
533% -------------------------------------------------------------------------------------------------------------
534%       Tracer/Dynamics Trends
535% -------------------------------------------------------------------------------------------------------------
536\subsection{Tracer/Dynamics Trends (\key{trdlmd}, \key{diatrdtra})}
537\label{MISC_tratrd}
538
539%to be udated this corresponds to OPA8
540When \key{diatrddyn} and/or \key{diatrddyn} cpp
541variables are defined, each trends of the dynamics and/or temperature and
542salinity time evolution equations are stored in three-dimensional arrays
543just after their computation (i.e. at the end of each $dyn\cdots .F$ 
544and/or $tra\cdots .F$ routines). These trends are then used in diagnostic
545routines $diadyn.F$ and $diatra.F$ respectively. In standard, these routines check the basin averaged properties of the momentum and tracer equations every \textit{ntrd } time-steps (\textbf{namelist parameter}). These routines
546are given as an example; they must be adapted by the user to his/her
547desiderata.
548
549These two options imply the definition of several arrays in the in core
550memory, increasing quite sensitively the code memory requirements (search
551for \key{diatrddyn} or
552\key{diatrdtra}in \textit{common.h} file)
553
554% -------------------------------------------------------------------------------------------------------------
555%       On-line Floats trajectories
556% -------------------------------------------------------------------------------------------------------------
557\subsection{On-line Floats trajectories}
558\label{FLO}
559%--------------------------------------------namflo-------------------------------------------------------
560\namdisplay{namflo} 
561%--------------------------------------------------------------------------------------------------------------
562
563\colorbox{yellow}{a description is to be added here}
564
565% -------------------------------------------------------------------------------------------------------------
566%       Other Diagnostics
567% -------------------------------------------------------------------------------------------------------------
568\subsection{Other Diagnostics}
569\label{MISC_diag_others}
570
571%To be updated  this corresponds to OPA 8
572
573Aside from the standard model variables, some other diagnostics are computed
574on-line or can be added in the model. The available ready-to-add diagnostics
575can be found in DIA. Among the available diagnostics one can
576quote:
577
578- the mixed layer depth (based on a density criterion) (\mdl{diamxl})
579
580- the turbocline depth (based on a turbulent mixing coefficient criterion) (\mdl{diamxl})
581
582- the depth of the 20\r{}C isotherm (\mdl{diahth})
583
584- the depth of the thermocline (maximum of the vertical temperature gradient) (\mdl{diahth})
585
586- the meridional heat and salt transports and their decomposition (\mdl{diamfl})
587
588- the surface pressure (\mdl{diaspr})
Note: See TracBrowser for help on using the repository browser.