[707] | 1 | % ================================================================ |
---|
| 2 | % Chapter Ñ Miscellaneous Topics |
---|
| 3 | % ================================================================ |
---|
[2282] | 4 | \chapter{Miscellaneous Topics} |
---|
[707] | 5 | \label{MISC} |
---|
| 6 | \minitoc |
---|
| 7 | |
---|
[2282] | 8 | \newpage |
---|
| 9 | $\ $\newline % force a new ligne |
---|
| 10 | |
---|
[707] | 11 | % ================================================================ |
---|
| 12 | % Representation of Unresolved Straits |
---|
| 13 | % ================================================================ |
---|
| 14 | \section{Representation of Unresolved Straits} |
---|
| 15 | \label{MISC_strait} |
---|
| 16 | |
---|
[2282] | 17 | In climate modeling, it often occurs that a crucial connections between water masses |
---|
| 18 | is broken as the grid mesh is too coarse to resolve narrow straits. For example, coarse |
---|
| 19 | grid spacing typically closes off the Mediterranean from the Atlantic at the Strait of |
---|
| 20 | Gibraltar. In this case, it is important for climate models to include the effects of salty |
---|
| 21 | water entering the Atlantic from the Mediterranean. Likewise, it is important for the |
---|
| 22 | Mediterranean to replenish its supply of water from the Atlantic to balance the net |
---|
| 23 | evaporation occurring over the Mediterranean region. This problem occurs even in |
---|
[2349] | 24 | eddy permitting simulations. For example, in ORCA 1/4\deg several straits of the Indonesian |
---|
[2282] | 25 | archipelago (Ombai, Lombok...) are much narrow than even a single ocean grid-point. |
---|
[707] | 26 | |
---|
[2282] | 27 | We describe briefly here the three methods that can be used in \NEMO to handle |
---|
| 28 | such improperly resolved straits. The first two consist of opening the strait by hand |
---|
| 29 | while ensuring that the mass exchanges through the strait are not too large by |
---|
| 30 | either artificially reducing the surface of the strait grid-cells or, locally increasing |
---|
| 31 | the lateral friction. In the third one, the strait is closed but exchanges of mass, |
---|
| 32 | heat and salt across the land are allowed. |
---|
| 33 | Note that such modifications are so specific to a given configuration that no attempt |
---|
| 34 | has been made to set them in a generic way. However, examples of how |
---|
[2349] | 35 | they can be set up is given in the ORCA 2\deg and 0.5\deg configurations (search for |
---|
| 36 | \key{orca\_r2} or \key{orca\_r05} in the code). |
---|
[707] | 37 | |
---|
| 38 | % ------------------------------------------------------------------------------------------------------------- |
---|
| 39 | % Hand made geometry changes |
---|
| 40 | % ------------------------------------------------------------------------------------------------------------- |
---|
| 41 | \subsection{Hand made geometry changes} |
---|
| 42 | \label{MISC_strait_hand} |
---|
| 43 | |
---|
[2282] | 44 | $\bullet$ reduced scale factor in the cross-strait direction to a value in better agreement |
---|
| 45 | with the true mean width of the strait. (Fig.~\ref{Fig_MISC_strait_hand}). |
---|
| 46 | This technique is sometime called "partially open face" or "partially closed cells". |
---|
| 47 | The key issue here is only to reduce the faces of $T$-cell ($i.e.$ change the value |
---|
| 48 | of the horizontal scale factors at $u$- or $v$-point) but not the volume of the $T$-cell. |
---|
| 49 | Indeed, reducing the volume of strait $T$-cell can easily produce a numerical |
---|
| 50 | instability at that grid point that would require a reduction of the model time step. |
---|
| 51 | The changes associated with strait management are done in \mdl{domhgr}, |
---|
| 52 | just after the definition or reading of the horizontal scale factors. |
---|
[707] | 53 | |
---|
[2282] | 54 | $\bullet$ increase of the viscous boundary layer thickness by local increase of the |
---|
| 55 | fmask value at the coast (Fig.~\ref{Fig_MISC_strait_hand}). This is done in |
---|
| 56 | \mdl{dommsk} together with the setting of the coastal value of fmask |
---|
| 57 | (see Section \ref{LBC_coast}) |
---|
[994] | 58 | |
---|
[707] | 59 | %>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
[2376] | 60 | \begin{figure}[!tbp] \begin{center} |
---|
[998] | 61 | \includegraphics[width=0.80\textwidth]{./TexFiles/Figures/Fig_Gibraltar.pdf} |
---|
| 62 | \includegraphics[width=0.80\textwidth]{./TexFiles/Figures/Fig_Gibraltar2.pdf} |
---|
[2376] | 63 | \caption{ \label{Fig_MISC_strait_hand} |
---|
| 64 | Example of the Gibraltar strait defined in a $1\deg \times 1\deg$ mesh. |
---|
[994] | 65 | \textit{Top}: using partially open cells. The meridional scale factor at $v$-point |
---|
| 66 | is reduced on both sides of the strait to account for the real width of the strait |
---|
[1224] | 67 | (about 20 km). Note that the scale factors of the strait $T$-point remains unchanged. |
---|
| 68 | \textit{Bottom}: using viscous boundary layers. The four fmask parameters |
---|
[994] | 69 | along the strait coastlines are set to a value larger than 4, $i.e.$ "strong" no-slip |
---|
| 70 | case (see Fig.\ref{Fig_LBC_shlat}) creating a large viscous boundary layer |
---|
| 71 | that allows a reduced transport through the strait.} |
---|
[707] | 72 | \end{center} \end{figure} |
---|
| 73 | %>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
| 74 | |
---|
| 75 | % ------------------------------------------------------------------------------------------------------------- |
---|
| 76 | % Cross Land Advection |
---|
| 77 | % ------------------------------------------------------------------------------------------------------------- |
---|
[2282] | 78 | \subsection{Cross Land Advection (\mdl{tracla})} |
---|
[707] | 79 | \label{MISC_strait_cla} |
---|
[1225] | 80 | %--------------------------------------------namcla-------------------------------------------------------- |
---|
| 81 | \namdisplay{namcla} |
---|
[707] | 82 | %-------------------------------------------------------------------------------------------------------------- |
---|
| 83 | |
---|
| 84 | \colorbox{yellow}{Add a short description of CLA staff here or in lateral boundary condition chapter?} |
---|
| 85 | |
---|
[2282] | 86 | %The problem is resolved here by allowing the mixing of tracers and mass/volume between non-adjacent water columns at nominated regions within the model. 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. |
---|
| 87 | |
---|
[707] | 88 | % ================================================================ |
---|
| 89 | % Closed seas |
---|
| 90 | % ================================================================ |
---|
[2282] | 91 | \section{Closed seas (\mdl{closea})} |
---|
[707] | 92 | \label{MISC_closea} |
---|
| 93 | |
---|
[2282] | 94 | \colorbox{yellow}{Add here a short description of the way closed seas are managed} |
---|
[707] | 95 | |
---|
[2282] | 96 | |
---|
[707] | 97 | % ================================================================ |
---|
| 98 | % Sub-Domain Functionality (\textit{nizoom, njzoom}, namelist parameters) |
---|
| 99 | % ================================================================ |
---|
| 100 | \section{Sub-Domain Functionality (\jp{jpizoom}, \jp{jpjzoom})} |
---|
| 101 | \label{MISC_zoom} |
---|
| 102 | |
---|
[994] | 103 | The sub-domain functionality, also improperly called the zoom option |
---|
| 104 | (improperly because it is not associated with a change in model resolution) |
---|
| 105 | is a quite simple function that allows a simulation over a sub-domain of an |
---|
| 106 | already defined configuration ($i.e.$ without defining a new mesh, initial |
---|
| 107 | state and forcings). This option can be useful for testing the user settings |
---|
| 108 | of surface boundary conditions, or the initial ocean state of a huge ocean |
---|
| 109 | model configuration while having a small computer memory requirement. |
---|
| 110 | It can also be used to easily test specific physics in a sub-domain (for example, |
---|
[2282] | 111 | see \citep{Madec_al_JPO96} for a test of the coupling used in the global ocean |
---|
[994] | 112 | version of OPA between sea-ice and ocean model over the Arctic or Antarctic |
---|
| 113 | ocean, using a sub-domain). In the standard model, this option does not |
---|
| 114 | include any specific treatment for the ocean boundaries of the sub-domain: |
---|
| 115 | they are considered as artificial vertical walls. Nevertheless, it is quite easy |
---|
| 116 | to add a restoring term toward a climatology in the vicinity of such boundaries |
---|
| 117 | (see \S\ref{TRA_dmp}). |
---|
[707] | 118 | |
---|
| 119 | In order to easily define a sub-domain over which the computation can be |
---|
| 120 | performed, the dimension of all input arrays (ocean mesh, bathymetry, |
---|
[994] | 121 | forcing, initial state, ...) are defined as \jp{jpidta}, \jp{jpjdta} and \jp{jpkdta} |
---|
| 122 | (\mdl{par\_oce} module), while the computational domain is defined through |
---|
| 123 | \jp{jpiglo}, \jp{jpjglo} and \jp{jpk} (\mdl{par\_oce} module). When running the |
---|
| 124 | model over the whole domain, the user sets \jp{jpiglo}=\jp{jpidta} \jp{jpjglo}=\jp{jpjdta} |
---|
| 125 | and \jp{jpk}=\jp{jpkdta}. When running the model over a sub-domain, the user |
---|
| 126 | has to provide the size of the sub-domain, (\jp{jpiglo}, \jp{jpjglo}, \jp{jpkglo}), |
---|
| 127 | and the indices of the south western corner as \jp{jpizoom} and \jp{jpjzoom} in |
---|
| 128 | the \mdl{par\_oce} module (Fig.~\ref{Fig_LBC_zoom}). |
---|
[707] | 129 | |
---|
[994] | 130 | Note that a third set of dimensions exist, \jp{jpi}, \jp{jpj} and \jp{jpk} which is |
---|
| 131 | actually used to perform the computation. It is set by default to \jp{jpi}=\jp{jpjglo} |
---|
| 132 | and \jp{jpj}=\jp{jpjglo}, except for massively parallel computing where the |
---|
| 133 | computational domain is laid out on local processor memories following a 2D |
---|
| 134 | horizontal splitting. % (see {\S}IV.2-c) ref to the section to be updated |
---|
[707] | 135 | |
---|
| 136 | %>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
[2376] | 137 | \begin{figure}[!ht] \begin{center} |
---|
[998] | 138 | \includegraphics[width=0.90\textwidth]{./TexFiles/Figures/Fig_LBC_zoom.pdf} |
---|
[2376] | 139 | \caption{ \label{Fig_LBC_zoom} |
---|
| 140 | Position of a model domain compared to the data input domain when the zoom functionality is used.} |
---|
[707] | 141 | \end{center} \end{figure} |
---|
| 142 | %>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | % ================================================================ |
---|
| 146 | % Accelerating the Convergence |
---|
| 147 | % ================================================================ |
---|
| 148 | \section{Accelerating the Convergence (\np{nn\_acc} = 1)} |
---|
| 149 | \label{MISC_acc} |
---|
| 150 | %--------------------------------------------namdom------------------------------------------------------- |
---|
| 151 | \namdisplay{namdom} |
---|
| 152 | %-------------------------------------------------------------------------------------------------------------- |
---|
| 153 | |
---|
[2282] | 154 | Searching an equilibrium state with an global ocean model requires a very long time |
---|
| 155 | integration period (a few thousand years for a global model). Due to the size of |
---|
| 156 | the time step required for numerical stability (less than a few hours), |
---|
| 157 | this usually requires a large elapsed time. In order to overcome this problem, |
---|
| 158 | \citet{Bryan1984} introduces a technique that is intended to accelerate |
---|
[994] | 159 | the spin up to equilibrium. It uses a larger time step in |
---|
[2282] | 160 | the tracer evolution equations than in the momentum evolution |
---|
[707] | 161 | equations. It does not affect the equilibrium solution but modifies the |
---|
| 162 | trajectory to reach it. |
---|
| 163 | |
---|
[994] | 164 | The acceleration of convergence option is used when \np{nn\_acc}=1. In that case, |
---|
[2282] | 165 | $\rdt=rn\_rdt$ is the time step of dynamics while $\widetilde{\rdt}=rdttra$ is the |
---|
| 166 | tracer time-step. the former is set from the \np{rn\_rdt} namelist parameter while the latter |
---|
| 167 | is computed using a hyperbolic tangent profile and the following namelist parameters : |
---|
| 168 | \np{rn\_rdtmin}, \np{rn\_rdtmax} and \np{rn\_rdth}. Those three parameters correspond |
---|
| 169 | to the surface value the deep ocean value and the depth at which the transition occurs, respectively. |
---|
| 170 | The set of prognostic equations to solve becomes: |
---|
[707] | 171 | \begin{equation} \label{Eq_acc} |
---|
| 172 | \begin{split} |
---|
| 173 | \frac{\partial \textbf{U}_h }{\partial t} |
---|
[2282] | 174 | &\equiv \frac{\textbf{U}_h ^{t+1}-\textbf{U}_h^{t-1} }{2\rdt} = \ldots \\ |
---|
| 175 | \frac{\partial T}{\partial t} &\equiv \frac{T^{t+1}-T^{t-1}}{2 \widetilde{\rdt}} = \ldots \\ |
---|
| 176 | \frac{\partial S}{\partial t} &\equiv \frac{S^{t+1} -S^{t-1}}{2 \widetilde{\rdt}} = \ldots \\ |
---|
[707] | 177 | \end{split} |
---|
| 178 | \end{equation} |
---|
| 179 | |
---|
[994] | 180 | \citet{Bryan1984} has examined the consequences of this distorted physics. |
---|
| 181 | Free waves have a slower phase speed, their meridional structure is slightly |
---|
[707] | 182 | modified, and the growth rate of baroclinically unstable waves is reduced |
---|
[994] | 183 | but with a wider range of instability. This technique is efficient for |
---|
| 184 | searching for an equilibrium state in coarse resolution models. However its |
---|
[707] | 185 | application is not suitable for many oceanic problems: it cannot be used for |
---|
| 186 | transient or time evolving problems (in particular, it is very questionable |
---|
[994] | 187 | to use this technique when there is a seasonal cycle in the forcing fields), |
---|
[707] | 188 | and it cannot be used in high-resolution models where baroclinically |
---|
| 189 | unstable processes are important. Moreover, the vertical variation of |
---|
[2282] | 190 | $\widetilde{ \rdt}$ implies that the heat and salt contents are no longer |
---|
[707] | 191 | conserved due to the vertical coupling of the ocean level through both |
---|
[2282] | 192 | advection and diffusion. Therefore \np{rn\_rdtmin} = \np{rn\_rdtmax} should be |
---|
| 193 | a more clever choice. |
---|
[707] | 194 | |
---|
[2541] | 195 | |
---|
[707] | 196 | % ================================================================ |
---|
[2541] | 197 | % Accuracy and Reproducibility |
---|
| 198 | % ================================================================ |
---|
| 199 | \section{Accuracy and Reproducibility (\mdl{lib\_fortran})} |
---|
| 200 | \label{MISC_fortran} |
---|
| 201 | |
---|
| 202 | \subsection{Issues with intrinsinc SIGN function (\key{nosignedzero})} |
---|
| 203 | \label{MISC_sign} |
---|
| 204 | |
---|
| 205 | The SIGN(A, B) is the \textsc {Fortran} intrinsic function delivers the magnitude |
---|
| 206 | of A with the sign of B. For example, SIGN(-3.0,2.0) has the value 3.0. |
---|
| 207 | The problematic case is when the second argument is zero, because, on platforms |
---|
| 208 | that support IEEE arithmetic, zero is actually a signed number. |
---|
| 209 | There is a positive zero and a negative zero. |
---|
| 210 | |
---|
| 211 | In \textsc{Fortran}~90, the processor was required always to deliver a positive result for SIGN(A, B) |
---|
| 212 | if B was zero. Nevertheless, in \textsc{Fortran}~95, the processor is allowed to do the correct thing |
---|
| 213 | and deliver ABS(A) when B is a positive zero and -ABS(A) when B is a negative zero. |
---|
| 214 | This change in the specification becomes apparent only when B is of type real, and is zero, |
---|
| 215 | and the processor is capable of distinguishing between positive and negative zero, |
---|
| 216 | and B is negative real zero. Then SIGN delivers a negative result where, under \textsc{Fortran}~90 |
---|
| 217 | rules, it used to return a positive result. |
---|
| 218 | This change may be especially sensitive for the ice model, so we overwrite the intrinsinc |
---|
| 219 | function with our own function simply performing : \\ |
---|
| 220 | \verb? IF( B >= 0.e0 ) THEN ; SIGN(A,B) = ABS(A) ? \\ |
---|
| 221 | \verb? ELSE ; SIGN(A,B) =-ABS(A) ? \\ |
---|
| 222 | \verb? ENDIF ? \\ |
---|
| 223 | This feature can be found in \mdl{lib\_fortran} module and is effective when \key{nosignedzero} |
---|
| 224 | is defined. We use a CPP key as the overwritting of a intrinsic function can present |
---|
| 225 | performance issues with some computers/compilers. |
---|
| 226 | |
---|
| 227 | |
---|
| 228 | \subsection{MPP reproducibility} |
---|
| 229 | \label{MISC_glosum} |
---|
| 230 | |
---|
| 231 | The numerical reproducibility of simulations on distributed memory parallel computers |
---|
| 232 | is a critical issue. In particular, within NEMO global summation of distributed arrays |
---|
| 233 | is most susceptible to rounding errors, and their propagation and accumulation cause |
---|
| 234 | uncertainty in final simulation reproducibility on different numbers of processors. |
---|
| 235 | To avoid so, based on \citet{He_Ding_JSC01} review of different technics, |
---|
| 236 | we use a so called self-compensated summation method. The idea is to estimate |
---|
| 237 | the roundoff error, store it in a buffer, and then add it back in the next addition. |
---|
| 238 | |
---|
| 239 | Suppose we need to calculate $b = a_1 + a_2 + a_3$. The following algorithm |
---|
| 240 | will allow to split the sum in two ($sum_1 = a_{1} + a_{2}$ and $b = sum_2 = sum_1 + a_3$) |
---|
| 241 | with exactly the same rounding errors as the sum performed all at once. |
---|
| 242 | \begin{align*} |
---|
| 243 | sum_1 \ \ &= a_1 + a_2 \\ |
---|
| 244 | error_1 &= a_2 + ( a_1 - sum_1 ) \\ |
---|
| 245 | sum_2 \ \ &= sum_1 + a_3 + error_1 \\ |
---|
| 246 | error_2 &= a_3 + error_1 + ( sum_1 - sum_2 ) \\ |
---|
| 247 | b \qquad \ &= sum_2 \\ |
---|
| 248 | \end{align*} |
---|
| 249 | This feature can be found in \mdl{lib\_fortran} module and is effective when \key{mpp\_rep}. |
---|
| 250 | In that case, all calls to glob\_sum function (summation over the entire basin excluding |
---|
| 251 | duplicated rows and columns due to cyclic or north fold boundary condition as well as |
---|
| 252 | overlap MPP areas). |
---|
| 253 | Note this implementation may be sensitive to the optimization level. |
---|
| 254 | |
---|
[3294] | 255 | \subsection{MPP scalability} |
---|
| 256 | \label{MISC_mppsca} |
---|
[2541] | 257 | |
---|
[3294] | 258 | The default method of communicating values across the north-fold in distributed memory applications |
---|
| 259 | (\key{mpp\_mpi}) uses a \textsc{MPI\_ALLGATHER} function to exchange values from each processing |
---|
| 260 | region in the northern row with every other processing region in the northern row. This enables a |
---|
| 261 | global width array containing the top 4 rows to be collated on every northern row processor and then |
---|
| 262 | folded with a simple algorithm. Although conceptually simple, this "All to All" communication will |
---|
| 263 | hamper performance scalability for large numbers of northern row processors. From version 3.4 |
---|
| 264 | onwards an alternative method is available which only performs direct "Peer to Peer" communications |
---|
| 265 | between each processor and its immediate "neighbours" across the fold line. This is achieved by |
---|
| 266 | using the default \textsc{MPI\_ALLGATHER} method during initialisation to help identify the "active" |
---|
| 267 | neighbours. Stored lists of these neighbours are then used in all subsequent north-fold exchanges to |
---|
| 268 | restrict exchanges to those between associated regions. The collated global width array for each |
---|
| 269 | region is thus only partially filled but is guaranteed to be set at all the locations actually |
---|
| 270 | required by each individual for the fold operation. This alternative method should give identical |
---|
| 271 | results to the default \textsc{ALLGATHER} method and is recommended for large values of \np{jpni}. |
---|
| 272 | The new method is activated by setting \np{ln\_nnogather} to be true ({\bf nammpp}). The |
---|
| 273 | reproducibility of results using the two methods should be confirmed for each new, non-reference |
---|
| 274 | configuration. |
---|
| 275 | |
---|
[2541] | 276 | % ================================================================ |
---|
[707] | 277 | % Model optimisation, Control Print and Benchmark |
---|
| 278 | % ================================================================ |
---|
[994] | 279 | \section{Model Optimisation, Control Print and Benchmark} |
---|
[707] | 280 | \label{MISC_opt} |
---|
[1225] | 281 | %--------------------------------------------namctl------------------------------------------------------- |
---|
| 282 | \namdisplay{namctl} |
---|
[707] | 283 | %-------------------------------------------------------------------------------------------------------------- |
---|
| 284 | |
---|
[2541] | 285 | \gmcomment{why not make these bullets into subsections?} |
---|
[707] | 286 | |
---|
[994] | 287 | |
---|
[2349] | 288 | $\bullet$ Vector optimisation: |
---|
[707] | 289 | |
---|
[2282] | 290 | \key{vectopt\_loop} enables the internal loops to collapse. This is very |
---|
| 291 | a very efficient way to increase the length of vector calculations and thus |
---|
| 292 | to speed up the model on vector computers. |
---|
[707] | 293 | |
---|
[994] | 294 | % Add here also one word on NPROMA technique that has been found useless, since compiler have made significant progress during the last decade. |
---|
[707] | 295 | |
---|
[994] | 296 | % Add also one word on NEC specific optimisation (Novercheck option for example) |
---|
[707] | 297 | |
---|
[994] | 298 | $\bullet$ Control print %: describe here 4 things: |
---|
[707] | 299 | |
---|
[994] | 300 | 1- \np{ln\_ctl} : compute and print the trends averaged over the interior domain |
---|
| 301 | in all TRA, DYN, LDF and ZDF modules. This option is very helpful when |
---|
| 302 | diagnosing the origin of an undesired change in model results. |
---|
[707] | 303 | |
---|
[994] | 304 | 2- also \np{ln\_ctl} but using the nictl and njctl namelist parameters to check |
---|
| 305 | the source of differences between mono and multi processor runs. |
---|
[707] | 306 | |
---|
[994] | 307 | 3- \key{esopa} (to be rename key\_nemo) : which is another option for model |
---|
| 308 | management. When defined, this key forces the activation of all options and |
---|
| 309 | CPP keys. For example, all tracer and momentum advection schemes are called! |
---|
[2282] | 310 | Therefore the model results have no physical meaning. |
---|
[994] | 311 | However, this option forces both the compiler and the model to run through |
---|
| 312 | all the \textsc{Fortran} lines of the model. This allows the user to check for obvious |
---|
| 313 | compilation or execution errors with all CPP options, and errors in namelist options. |
---|
[707] | 314 | |
---|
[2282] | 315 | 4- last digit comparison (\np{nn\_bit\_cmp}). In an MPP simulation, the computation of |
---|
[994] | 316 | a sum over the whole domain is performed as the summation over all processors of |
---|
| 317 | each of their sums over their interior domains. This double sum never gives exactly |
---|
| 318 | the same result as a single sum over the whole domain, due to truncation differences. |
---|
| 319 | The "bit comparison" option has been introduced in order to be able to check that |
---|
| 320 | mono-processor and multi-processor runs give exactly the same results. |
---|
[2376] | 321 | %THIS is to be updated with the mpp_sum_glo introduced in v3.3 |
---|
| 322 | % nn_bit_cmp today only check that the nn_cla = 0 (no cross land advection) |
---|
[707] | 323 | |
---|
[2282] | 324 | $\bullet$ Benchmark (\np{nn\_bench}). This option defines a benchmark run based on |
---|
[2376] | 325 | a GYRE configuration (see \S\ref{CFG_gyre}) in which the resolution remains the same |
---|
| 326 | whatever the domain size. This allows a very large model domain to be used, just by |
---|
| 327 | changing the domain size (\jp{jpiglo}, \jp{jpjglo}) and without adjusting either the time-step |
---|
| 328 | or the physical parameterisations. |
---|
[707] | 329 | |
---|
| 330 | |
---|
| 331 | % ================================================================ |
---|
| 332 | % Elliptic solvers (SOL) |
---|
| 333 | % ================================================================ |
---|
[2282] | 334 | \section{Elliptic solvers (SOL)} |
---|
[707] | 335 | \label{MISC_sol} |
---|
| 336 | %--------------------------------------------namdom------------------------------------------------------- |
---|
| 337 | \namdisplay{namsol} |
---|
| 338 | %-------------------------------------------------------------------------------------------------------------- |
---|
| 339 | |
---|
[2282] | 340 | When the filtered sea surface height option is used, the surface pressure gradient is |
---|
| 341 | computed in \mdl{dynspg\_flt}. The force added in the momentum equation is solved implicitely. |
---|
| 342 | It is thus solution of an elliptic equation \eqref{Eq_PE_flt} for which two solvers are available: |
---|
| 343 | a Successive-Over-Relaxation scheme (SOR) and a preconditioned conjugate gradient |
---|
| 344 | scheme(PCG) \citep{Madec_al_OM88, Madec_PhD90}. The solver is selected trough the |
---|
| 345 | the value of \np{nn\_solv} (namelist parameter). |
---|
| 346 | |
---|
[994] | 347 | The PCG is a very efficient method for solving elliptic equations on vector computers. |
---|
| 348 | It is a fast and rather easy method to use; which are attractive features for a large |
---|
| 349 | number of ocean situations (variable bottom topography, complex coastal geometry, |
---|
[2541] | 350 | variable grid spacing, open or cyclic boundaries, etc ...). It does not require |
---|
[994] | 351 | a search for an optimal parameter as in the SOR method. However, the SOR has |
---|
| 352 | been retained because it is a linear solver, which is a very useful property when |
---|
[2282] | 353 | using the adjoint model of \NEMO. |
---|
[707] | 354 | |
---|
[2282] | 355 | At each time step, the time derivative of the sea surface height at time step $t+1$ |
---|
| 356 | (or equivalently the divergence of the \textit{after} barotropic transport) that appears |
---|
| 357 | in the filtering forced is the solution of the elliptic equation obtained from the horizontal |
---|
| 358 | divergence of the vertical summation of \eqref{Eq_PE_flt}. |
---|
| 359 | Introducing the following coefficients: |
---|
| 360 | \begin{equation} \label{Eq_sol_matrix} |
---|
[707] | 361 | \begin{aligned} |
---|
[2282] | 362 | &c_{i,j}^{NS} &&= {2 \rdt }^2 \; \frac{H_v (i,j) \; e_{1v} (i,j)}{e_{2v}(i,j)} \\ |
---|
| 363 | &c_{i,j}^{EW} &&= {2 \rdt }^2 \; \frac{H_u (i,j) \; e_{2u} (i,j)}{e_{1u}(i,j)} \\ |
---|
| 364 | &b_{i,j} &&= \delta_i \left[ e_{2u}M_u \right] - \delta_j \left[ e_{1v}M_v \right]\ , \\ |
---|
[707] | 365 | \end{aligned} |
---|
| 366 | \end{equation} |
---|
[2541] | 367 | the resulting five-point finite difference equation is given by: |
---|
[2282] | 368 | \begin{equation} \label{Eq_solmat} |
---|
| 369 | \begin{split} |
---|
| 370 | c_{i+1,j}^{NS} D_{i+1,j} + \; c_{i,j+1}^{EW} D_{i,j+1} |
---|
| 371 | + c_{i,j} ^{NS} D_{i-1,j} + \; c_{i,j} ^{EW} D_{i,j-1} & \\ |
---|
| 372 | - \left(c_{i+1,j}^{NS} + c_{i,j+1}^{EW} + c_{i,j}^{NS} + c_{i,j}^{EW} \right) D_{i,j} &= b_{i,j} |
---|
| 373 | \end{split} |
---|
| 374 | \end{equation} |
---|
[996] | 375 | \eqref{Eq_solmat} is a linear symmetric system of equations. All the elements of |
---|
| 376 | the corresponding matrix \textbf{A} vanish except those of five diagonals. With |
---|
[707] | 377 | the natural ordering of the grid points (i.e. from west to east and from |
---|
| 378 | south to north), the structure of \textbf{A} is block-tridiagonal with |
---|
| 379 | tridiagonal or diagonal blocks. \textbf{A} is a positive-definite symmetric |
---|
| 380 | matrix of size $(jpi \cdot jpj)^2$, and \textbf{B}, the right hand side of |
---|
| 381 | \eqref{Eq_solmat}, is a vector. |
---|
| 382 | |
---|
[2282] | 383 | Note that in the linear free surface case, the depth that appears in \eqref{Eq_sol_matrix} |
---|
| 384 | does not vary with time, and thus the matrix can be computed once for all. In non-linear free surface |
---|
| 385 | (\key{vvl} defined) the matrix have to be updated at each time step. |
---|
| 386 | |
---|
[707] | 387 | % ------------------------------------------------------------------------------------------------------------- |
---|
| 388 | % Successive Over Relaxation |
---|
| 389 | % ------------------------------------------------------------------------------------------------------------- |
---|
[2282] | 390 | \subsection{Successive Over Relaxation (\np{nn\_solv}=2, \mdl{solsor})} |
---|
[707] | 391 | \label{MISC_solsor} |
---|
| 392 | |
---|
[2282] | 393 | Let us introduce the four cardinal coefficients: |
---|
| 394 | \begin{align*} |
---|
| 395 | a_{i,j}^S &= c_{i,j }^{NS}/d_{i,j} &\qquad a_{i,j}^W &= c_{i,j}^{EW}/d_{i,j} \\ |
---|
| 396 | a_{i,j}^E &= c_{i,j+1}^{EW}/d_{i,j} &\qquad a_{i,j}^N &= c_{i+1,j}^{NS}/d_{i,j} |
---|
| 397 | \end{align*} |
---|
| 398 | where $d_{i,j} = c_{i,j}^{NS}+ c_{i+1,j}^{NS} + c_{i,j}^{EW} + c_{i,j+1}^{EW}$ |
---|
| 399 | (i.e. the diagonal of the matrix). \eqref{Eq_solmat} can be rewritten as: |
---|
| 400 | \begin{equation} \label{Eq_solmat_p} |
---|
| 401 | \begin{split} |
---|
| 402 | a_{i,j}^{N} D_{i+1,j} +\,a_{i,j}^{E} D_{i,j+1} +\, a_{i,j}^{S} D_{i-1,j} +\,a_{i,j}^{W} D_{i,j-1} - D_{i,j} = \tilde{b}_{i,j} |
---|
| 403 | \end{split} |
---|
| 404 | \end{equation} |
---|
| 405 | with $\tilde b_{i,j} = b_{i,j}/d_{i,j}$. \eqref{Eq_solmat_p} is the equation actually solved |
---|
| 406 | with the SOR method. This method used is an iterative one. Its algorithm can be |
---|
| 407 | summarised as follows (see \citet{Haltiner1980} for a further discussion): |
---|
[707] | 408 | |
---|
[994] | 409 | initialisation (evaluate a first guess from previous time step computations) |
---|
[707] | 410 | \begin{equation} |
---|
[2282] | 411 | D_{i,j}^0 = 2 \, D_{i,j}^t - D_{i,j}^{t-1} |
---|
[707] | 412 | \end{equation} |
---|
[994] | 413 | iteration $n$, from $n=0$ until convergence, do : |
---|
[2282] | 414 | \begin{equation} \label{Eq_sor_algo} |
---|
| 415 | \begin{split} |
---|
| 416 | R_{i,j}^n = &a_{i,j}^{N} D_{i+1,j}^n +\,a_{i,j}^{E} D_{i,j+1} ^n |
---|
| 417 | +\, a_{i,j}^{S} D_{i-1,j} ^{n+1}+\,a_{i,j}^{W} D_{i,j-1} ^{n+1} |
---|
| 418 | - D_{i,j}^n - \tilde{b}_{i,j} \\ |
---|
| 419 | D_{i,j} ^{n+1} = &D_{i,j} ^{n} + \omega \;R_{i,j}^n |
---|
| 420 | \end{split} |
---|
[707] | 421 | \end{equation} |
---|
[994] | 422 | where \textit{$\omega $ }satisfies $1\leq \omega \leq 2$. An optimal value exists for |
---|
| 423 | \textit{$\omega$} which significantly accelerates the convergence, but it has to be |
---|
| 424 | adjusted empirically for each model domain (except for a uniform grid where an |
---|
| 425 | analytical expression for \textit{$\omega$} can be found \citep{Richtmyer1967}). |
---|
[2282] | 426 | The value of $\omega$ is set using \np{rn\_sor}, a \textbf{namelist} parameter. |
---|
[994] | 427 | The convergence test is of the form: |
---|
[707] | 428 | \begin{equation} |
---|
[2282] | 429 | \delta = \frac{\sum\limits_{i,j}{R_{i,j}^n}{R_{i,j}^n}} |
---|
| 430 | {\sum\limits_{i,j}{ \tilde{b}_{i,j}^n}{\tilde{b}_{i,j}^n}} \leq \epsilon |
---|
[707] | 431 | \end{equation} |
---|
[994] | 432 | where $\epsilon$ is the absolute precision that is required. It is recommended |
---|
[2282] | 433 | that a value smaller or equal to $10^{-6}$ is used for $\epsilon$ since larger |
---|
| 434 | values may lead to numerically induced basin scale barotropic oscillations. |
---|
| 435 | The precision is specified by setting \np{rn\_eps} (\textbf{namelist} parameter). |
---|
| 436 | In addition, two other tests are used to halt the iterative algorithm. They involve |
---|
| 437 | the number of iterations and the modulus of the right hand side. If the former |
---|
| 438 | exceeds a specified value, \np{nn\_max} (\textbf{namelist} parameter), |
---|
| 439 | or the latter is greater than $10^{15}$, the whole model computation is stopped |
---|
| 440 | and the last computed time step fields are saved in a abort.nc NetCDF file. |
---|
| 441 | In both cases, this usually indicates that there is something wrong in the model |
---|
| 442 | configuration (an error in the mesh, the initial state, the input forcing, |
---|
[994] | 443 | or the magnitude of the time step or of the mixing coefficients). A typical value of |
---|
[2282] | 444 | $nn\_max$ is a few hundred when $\epsilon = 10^{-6}$, increasing to a few |
---|
[994] | 445 | thousand when $\epsilon = 10^{-12}$. |
---|
| 446 | The vectorization of the SOR algorithm is not straightforward. The scheme |
---|
| 447 | contains two linear recurrences on $i$ and $j$. This inhibits the vectorisation. |
---|
[2282] | 448 | \eqref{Eq_sor_algo} can be been rewritten as: |
---|
| 449 | \begin{equation} |
---|
| 450 | \begin{split} |
---|
[707] | 451 | R_{i,j}^n |
---|
[2282] | 452 | = &a_{i,j}^{N} D_{i+1,j}^n +\,a_{i,j}^{E} D_{i,j+1} ^n |
---|
| 453 | +\,a_{i,j}^{S} D_{i-1,j} ^{n}+\,_{i,j}^{W} D_{i,j-1} ^{n} - D_{i,j}^n - \tilde{b}_{i,j} \\ |
---|
| 454 | R_{i,j}^n = &R_{i,j}^n - \omega \;a_{i,j}^{S}\; R_{i,j-1}^n \\ |
---|
| 455 | R_{i,j}^n = &R_{i,j}^n - \omega \;a_{i,j}^{W}\; R_{i-1,j}^n |
---|
| 456 | \end{split} |
---|
[707] | 457 | \end{equation} |
---|
[2282] | 458 | This technique slightly increases the number of iteration required to reach the convergence, |
---|
| 459 | but this is largely compensated by the gain obtained by the suppression of the recurrences. |
---|
[707] | 460 | |
---|
[2282] | 461 | Another technique have been chosen, the so-called red-black SOR. It consist in solving successively |
---|
| 462 | \eqref{Eq_sor_algo} for odd and even grid points. It also slightly reduced the convergence rate |
---|
| 463 | but allows the vectorisation. In addition, and this is the reason why it has been chosen, it is able to handle the north fold boundary condition used in ORCA configuration ($i.e.$ tri-polar global ocean mesh). |
---|
[707] | 464 | |
---|
[2282] | 465 | The SOR method is very flexible and can be used under a wide range of conditions, |
---|
| 466 | including irregular boundaries, interior boundary points, etc. Proofs of convergence, etc. |
---|
| 467 | may be found in the standard numerical methods texts for partial differential equations. |
---|
[707] | 468 | |
---|
| 469 | % ------------------------------------------------------------------------------------------------------------- |
---|
| 470 | % Preconditioned Conjugate Gradient |
---|
| 471 | % ------------------------------------------------------------------------------------------------------------- |
---|
[2282] | 472 | \subsection{Preconditioned Conjugate Gradient (\np{nn\_solv}=1, \mdl{solpcg}) } |
---|
[707] | 473 | \label{MISC_solpcg} |
---|
| 474 | |
---|
| 475 | \textbf{A} is a definite positive symmetric matrix, thus solving the linear |
---|
[994] | 476 | system \eqref{Eq_solmat} is equivalent to the minimisation of a quadratic |
---|
[707] | 477 | functional: |
---|
| 478 | \begin{equation*} |
---|
| 479 | \textbf{Ax} = \textbf{b} \leftrightarrow \textbf{x} =\text{inf}_{y} \,\phi (\textbf{y}) |
---|
| 480 | \quad , \qquad |
---|
| 481 | \phi (\textbf{y}) = 1/2 \langle \textbf{Ay},\textbf{y}\rangle - \langle \textbf{b},\textbf{y} \rangle |
---|
| 482 | \end{equation*} |
---|
| 483 | where $\langle , \rangle$ is the canonical dot product. The idea of the |
---|
[994] | 484 | conjugate gradient method is to search for the solution in the following |
---|
| 485 | iterative way: assuming that $\textbf{x}^n$ has been obtained, $\textbf{x}^{n+1}$ |
---|
| 486 | is found from $\textbf {x}^{n+1}={\textbf {x}}^n+\alpha^n{\textbf {d}}^n$ which satisfies: |
---|
[707] | 487 | \begin{equation*} |
---|
[994] | 488 | {\textbf{ x}}^{n+1}=\text{inf} _{{\textbf{ y}}={\textbf{ x}}^n+\alpha^n \,{\textbf{ d}}^n} \,\phi ({\textbf{ y}})\;\;\Leftrightarrow \;\;\frac{d\phi }{d\alpha}=0 |
---|
[707] | 489 | \end{equation*} |
---|
[1224] | 490 | and expressing $\phi (\textbf{y})$ as a function of \textit{$\alpha $}, we obtain the |
---|
| 491 | value that minimises the functional: |
---|
[707] | 492 | \begin{equation*} |
---|
| 493 | \alpha ^n = \langle{ \textbf{r}^n , \textbf{r}^n} \rangle / \langle {\textbf{ A d}^n, \textbf{d}^n} \rangle |
---|
| 494 | \end{equation*} |
---|
[994] | 495 | where $\textbf{r}^n = \textbf{b}-\textbf{A x}^n = \textbf{A} (\textbf{x}-\textbf{x}^n)$ |
---|
| 496 | is the error at rank $n$. The descent vector $\textbf{d}^n$ s chosen to be dependent |
---|
| 497 | on the error: $\textbf{d}^n = \textbf{r}^n + \beta^n \,\textbf{d}^{n-1}$. $\beta ^n$ |
---|
| 498 | is searched such that the descent vectors form an orthogonal basis for the dot |
---|
| 499 | product linked to \textbf{A}. Expressing the condition |
---|
[707] | 500 | $\langle \textbf{A d}^n, \textbf{d}^{n-1} \rangle = 0$ the value of $\beta ^n$ is found: |
---|
[1224] | 501 | $\beta ^n = \langle{ \textbf{r}^n , \textbf{r}^n} \rangle / \langle {\textbf{r}^{n-1}, \textbf{r}^{n-1}} \rangle$. |
---|
| 502 | As a result, the errors $ \textbf{r}^n$ form an orthogonal |
---|
[994] | 503 | base for the canonic dot product while the descent vectors $\textbf{d}^n$ form |
---|
[707] | 504 | an orthogonal base for the dot product linked to \textbf{A}. The resulting |
---|
| 505 | algorithm is thus the following one: |
---|
| 506 | |
---|
| 507 | initialisation : |
---|
| 508 | \begin{equation*} |
---|
[2282] | 509 | \begin{split} |
---|
| 510 | \textbf{x}^0 &= D_{i,j}^0 = 2 D_{i,j}^t - D_{i,j}^{t-1} \quad, \text{the initial guess } \\ |
---|
| 511 | \textbf{r}^0 &= \textbf{d}^0 = \textbf{b} - \textbf{A x}^0 \\ |
---|
| 512 | \gamma_0 &= \langle{ \textbf{r}^0 , \textbf{r}^0} \rangle |
---|
| 513 | \end{split} |
---|
[707] | 514 | \end{equation*} |
---|
| 515 | |
---|
| 516 | iteration $n,$ from $n=0$ until convergence, do : |
---|
| 517 | \begin{equation} |
---|
| 518 | \begin{split} |
---|
| 519 | \text{z}^n& = \textbf{A d}^n \\ |
---|
[2282] | 520 | \alpha_n &= \gamma_n / \langle{ \textbf{z}^n , \textbf{d}^n} \rangle \\ |
---|
[707] | 521 | \textbf{x}^{n+1} &= \textbf{x}^n + \alpha_n \,\textbf{d}^n \\ |
---|
| 522 | \textbf{r}^{n+1} &= \textbf{r}^n - \alpha_n \,\textbf{z}^n \\ |
---|
| 523 | \gamma_{n+1} &= \langle{ \textbf{r}^{n+1} , \textbf{r}^{n+1}} \rangle \\ |
---|
| 524 | \beta_{n+1} &= \gamma_{n+1}/\gamma_{n} \\ |
---|
| 525 | \textbf{d}^{n+1} &= \textbf{r}^{n+1} + \beta_{n+1}\; \textbf{d}^{n}\\ |
---|
| 526 | \end{split} |
---|
| 527 | \end{equation} |
---|
| 528 | |
---|
| 529 | |
---|
| 530 | The convergence test is: |
---|
| 531 | \begin{equation} |
---|
| 532 | \delta = \gamma_{n}\; / \langle{ \textbf{b} , \textbf{b}} \rangle \leq \epsilon |
---|
| 533 | \end{equation} |
---|
| 534 | where $\epsilon $ is the absolute precision that is required. As for the SOR algorithm, |
---|
[2282] | 535 | the whole model computation is stopped when the number of iterations, \np{nn\_max}, or |
---|
[994] | 536 | the modulus of the right hand side of the convergence equation exceeds a |
---|
| 537 | specified value (see \S\ref{MISC_solsor} for a further discussion). The required |
---|
| 538 | precision and the maximum number of iterations allowed are specified by setting |
---|
[2282] | 539 | \np{rn\_eps} and \np{nn\_max} (\textbf{namelist} parameters). |
---|
[707] | 540 | |
---|
[994] | 541 | It can be demonstrated that the above algorithm is optimal, provides the exact |
---|
[707] | 542 | solution in a number of iterations equal to the size of the matrix, and that |
---|
[994] | 543 | the convergence rate is faster as the matrix is closer to the identity matrix, |
---|
[2282] | 544 | $i.e.$ its eigenvalues are closer to 1. Therefore, it is more efficient to solve |
---|
| 545 | a better conditioned system which has the same solution. For that purpose, |
---|
| 546 | we introduce a preconditioning matrix \textbf{Q} which is an approximation |
---|
| 547 | of \textbf{A} but much easier to invert than \textbf{A}, and solve the system: |
---|
[994] | 548 | \begin{equation} \label{Eq_pmat} |
---|
[707] | 549 | \textbf{Q}^{-1} \textbf{A x} = \textbf{Q}^{-1} \textbf{b} |
---|
| 550 | \end{equation} |
---|
| 551 | |
---|
[994] | 552 | The same algorithm can be used to solve \eqref{Eq_pmat} if instead of the |
---|
| 553 | canonical dot product the following one is used: |
---|
[1224] | 554 | ${\langle{ \textbf{a} , \textbf{b}} \rangle}_Q = \langle{ \textbf{a} , \textbf{Q b}} \rangle$, and |
---|
| 555 | if $\textbf{\~{b}} = \textbf{Q}^{-1}\;\textbf{b}$ and $\textbf{\~{A}} = \textbf{Q}^{-1}\;\textbf{A}$ |
---|
[2282] | 556 | are substituted to \textbf{b} and \textbf{A} \citep{Madec_al_OM88}. |
---|
[1224] | 557 | In \NEMO, \textbf{Q} is chosen as the diagonal of \textbf{ A}, i.e. the simplest form for |
---|
| 558 | \textbf{Q} so that it can be easily inverted. In this case, the discrete formulation of |
---|
[994] | 559 | \eqref{Eq_pmat} is in fact given by \eqref{Eq_solmat_p} and thus the matrix and |
---|
| 560 | right hand side are computed independently from the solver used. |
---|
[707] | 561 | |
---|
| 562 | % ================================================================ |
---|
| 563 | |
---|
| 564 | |
---|
[2282] | 565 | |
---|
[707] | 566 | |
---|
| 567 | |
---|
[2364] | 568 | |
---|
| 569 | |
---|
| 570 | |
---|
| 571 | |
---|
| 572 | |
---|
| 573 | |
---|
| 574 | |
---|