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 NEMO/trunk/doc/latex/NEMO/subfiles – NEMO

source: NEMO/trunk/doc/latex/NEMO/subfiles/chap_misc.tex @ 11571

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

Cosmetic modifications on section titles

File size: 22.2 KB
RevLine 
[10414]1\documentclass[../main/NEMO_manual]{subfiles}
2
[6997]3\begin{document}
[707]4% ================================================================
[10414]5% Chapter --- Miscellaneous Topics
[707]6% ================================================================
[2282]7\chapter{Miscellaneous Topics}
[9407]8\label{chap:MISC}
[10414]9
[11435]10\chaptertoc
[707]11
[2282]12\newpage
13
[707]14% ================================================================
15% Representation of Unresolved Straits
16% ================================================================
[9393]17\section{Representation of unresolved straits}
[9407]18\label{sec:MISC_strait}
[707]19
[10354]20In climate modeling, it often occurs that a crucial connections between water masses is broken as
21the grid mesh is too coarse to resolve narrow straits.
22For example, coarse grid spacing typically closes off the Mediterranean from the Atlantic at
23the Strait of Gibraltar.
24In this case, it is important for climate models to include the effects of salty water entering the Atlantic from
25the Mediterranean.
26Likewise, it is important for the Mediterranean to replenish its supply of water from the Atlantic to
27balance the net evaporation occurring over the Mediterranean region.
28This problem occurs even in eddy permitting simulations.
[11558]29For example, in ORCA 1/4\deg\ several straits of the Indonesian archipelago (Ombai, Lombok...)
[10354]30are much narrow than even a single ocean grid-point.
[707]31
[11435]32We describe briefly here the two methods that can be used in \NEMO\ to handle such
[11339]33improperly resolved straits. The methods consist of opening the strait while ensuring
34that the mass exchanges through the strait are not too large by either artificially
35reducing the cross-sectional area of the strait grid-cells or, locally increasing the
36lateral friction.
[707]37
38% -------------------------------------------------------------------------------------------------------------
39%       Hand made geometry changes
40% -------------------------------------------------------------------------------------------------------------
41\subsection{Hand made geometry changes}
[9407]42\label{subsec:MISC_strait_hand}
[707]43
[11339]44The first method involves reducing the scale factor in the cross-strait direction to a
45value in better agreement with the true mean width of the strait
46(\autoref{fig:MISC_strait_hand}).  This technique is sometime called "partially open face"
47or "partially closed cells".  The key issue here is only to reduce the faces of $T$-cell
[11435]48(\ie\ change the value of the horizontal scale factors at $u$- or $v$-point) but not the
[11339]49volume of the $T$-cell.  Indeed, reducing the volume of strait $T$-cell can easily produce
50a numerical instability at that grid point which would require a reduction of the model
51time step.  Thus to instigate a local change in the width of a Strait requires two steps:
[707]52
[11339]53\begin{itemize}
[994]54
[11339]55\item Add \texttt{e1e2u} and \texttt{e1e2v} arrays to the \np{cn\_domcfg} file. These 2D
56arrays should contain the products of the unaltered values of: $\texttt{e1u}*\texttt{e2u}$
57and $\texttt{e1u}*\texttt{e2v}$ respectively. That is the original surface areas of $u$-
58and $v$- cells respectively.  These areas are usually defined by the corresponding product
[11435]59within the \NEMO\ code but the presence of \texttt{e1e2u} and \texttt{e1e2v} in the
[11339]60\np{cn\_domcfg} file will suppress this calculation and use the supplied fields instead.
61If the model domain is provided by user-supplied code in \mdl{usrdef\_hgr}, then this
62routine should also return \texttt{e1e2u} and \texttt{e1e2v} and set the integer return
63argument \texttt{ie1e2u\_v} to a non-zero value. Values other than 0 for this argument
64will suppress the calculation of the areas.
65
66\item Change values of \texttt{e2u} or \texttt{e1v} (either in the \np{cn\_domcfg} file or
67via code in  \mdl{usrdef\_hgr}), whereever a Strait reduction is required. The choice of
68whether to alter \texttt{e2u} or \texttt{e1v} depends. respectively,  on whether the
[11435]69Strait in question is North-South orientated (\eg\ Gibraltar) or East-West orientated (\eg
[11339]70Lombok).
71
72\end{itemize}
73
74The second method is to increase the viscous boundary layer thickness by a local increase
75of the fmask value at the coast. This method can also be effective in wider passages.  The
76concept is illustarted in the second part of  \autoref{fig:MISC_strait_hand} and changes
77to specific locations can be coded in \mdl{usrdef\_fmask}. The \forcode{usr_def_fmask}
78routine is always called after \texttt{fmask} has been defined according to the choice of
79lateral boundary condition as discussed in \autoref{sec:LBC_coast}. The default version of
80\mdl{usrdef\_fmask} contains settings specific to ORCA2 and ORCA1 configurations. These are
81meant as examples only; it is up to the user to verify settings and provide alternatives
82for their own configurations. The default \forcode{usr_def_fmask} makes no changes to
83\texttt{fmask} for any other configuration.
84
[707]85%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[10354]86\begin{figure}[!tbp]
[11558]87  \centering
[11561]88  \includegraphics[width=0.66\textwidth]{Fig_Gibraltar}
89  \includegraphics[width=0.66\textwidth]{Fig_Gibraltar2}
[11558]90  \caption[Two methods to defined the Gibraltar strait]{
91    Example of the Gibraltar strait defined in a 1\deg\ $\times$ 1\deg\ mesh.
92    \textit{Top}: using partially open cells.
93    The meridional scale factor at $v$-point is reduced on both sides of the strait to
94    account for the real width of the strait (about 20 km).
95    Note that the scale factors of the strait $T$-point remains unchanged.
96    \textit{Bottom}: using viscous boundary layers.
97    The four fmask parameters along the strait coastlines are set to a value larger than 4,
98    \ie\ "strong" no-slip case (see \autoref{fig:LBC_shlat}) creating a large viscous boundary layer
99    that allows a reduced transport through the strait.}
100  \label{fig:MISC_strait_hand}
[10354]101\end{figure}
[707]102%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
103
[10462]104%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
105\begin{figure}[!tbp]
[11558]106  \centering
[11561]107  \includegraphics[width=0.66\textwidth]{Fig_closea_mask_example}
[11558]108  \caption[Mask fields for the \protect\mdl{closea} module]{
109    Example of mask fields for the \protect\mdl{closea} module.
110    \textit{Left}: a closea\_mask field;
111    \textit{Right}: a closea\_mask\_rnf field.
112    In this example, if \protect\np{ln\_closea} is set to \forcode{.true.},
113    the mean freshwater flux over each of the American Great Lakes will be set to zero,
114    and the total residual for all the lakes, if negative, will be put into
115    the St Laurence Seaway in the area shown.}
116  \label{fig:MISC_closea_mask_example}
[10462]117\end{figure}
118%>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[707]119
120% ================================================================
121% Closed seas
122% ================================================================
[11571]123\section[Closed seas (\textit{closea.F90})]{Closed seas (\protect\mdl{closea})}
[9407]124\label{sec:MISC_closea}
[707]125
[10462]126Some configurations include inland seas and lakes as ocean
127points. This is particularly the case for configurations that are
128coupled to an atmosphere model where one might want to include inland
129seas and lakes as ocean model points in order to provide a better
130bottom boundary condition for the atmosphere. However there is no
131route for freshwater to run off from the lakes to the ocean and this
132can lead to large drifts in the sea surface height over the lakes. The
133closea module provides options to either fill in closed seas and lakes
134at run time, or to set the net surface freshwater flux for each lake
135to zero and put the residual flux into the ocean.
[707]136
[11435]137Prior to \NEMO\ 4 the locations of inland seas and lakes was set via
138hardcoded indices for various ORCA configurations. From \NEMO\ 4 onwards
[10462]139the inland seas and lakes are defined using mask fields in the
140domain configuration file. The options are as follows.
[2282]141
[10462]142\begin{enumerate}
[11151]143\item{{\bfseries No ``closea\_mask'' field is included in domain configuration
[10462]144  file.} In this case the closea module does nothing.}
145
[11151]146\item{{\bfseries A field called closea\_mask is included in the domain
[10462]147configuration file and ln\_closea=.false. in namelist namcfg.} In this
148case the inland seas defined by the closea\_mask field are filled in
149(turned to land points) at run time. That is every point in
150closea\_mask that is nonzero is set to be a land point.}
151
[11151]152\item{{\bfseries A field called closea\_mask is included in the domain
[10462]153configuration file and ln\_closea=.true. in namelist namcfg.} Each
154inland sea or group of inland seas is set to a positive integer value
[11543]155in the closea\_mask field (see \autoref{fig:MISC_closea_mask_example}
[10462]156for an example). The net surface flux over each inland sea or group of
157inland seas is set to zero each timestep and the residual flux is
158distributed over the global ocean (ie. all ocean points where
159closea\_mask is zero).}
160
[11151]161\item{{\bfseries Fields called closea\_mask and closea\_mask\_rnf are
[10462]162included in the domain configuration file and ln\_closea=.true. in
163namelist namcfg.} This option works as for option 3, except that if
164the net surface flux over an inland sea is negative (net
165precipitation) it is put into the ocean at specified runoff points. A
166net positive surface flux (net evaporation) is still spread over the
167global ocean. The mapping from inland seas to runoff points is defined
168by the closea\_mask\_rnf field. Each mapping is defined by a positive
169integer value for the inland sea(s) and the corresponding runoff
[11543]170points. An example is given in
171\autoref{fig:MISC_closea_mask_example}. If no mapping is provided for a
[10462]172particular inland sea then the residual is spread over the global
173ocean.}
174
[11151]175\item{{\bfseries Fields called closea\_mask and closea\_mask\_emp are
[10462]176included in the domain configuration file and ln\_closea=.true. in
177namelist namcfg.} This option works the same as option 4 except that
178the nonzero net surface flux is sent to the ocean at the specified
179runoff points regardless of whether it is positive or negative. The
180mapping from inland seas to runoff points in this case is defined by
181the closea\_mask\_emp field.}
182\end{enumerate}
183
184There is a python routine to create the closea\_mask fields and append
[11435]185them to the domain configuration file in the utils/tools/DOMAINcfg directory.
[10462]186
[707]187% ================================================================
[11435]188% Sub-Domain Functionality
[707]189% ================================================================
[9393]190\section{Sub-domain functionality}
[9407]191\label{sec:MISC_zoom}
[707]192
[9393]193\subsection{Simple subsetting of input files via NetCDF attributes}
[5118]194
[11339]195The extended grids for use with the under-shelf ice cavities will result in redundant rows
196around Antarctica if the ice cavities are not active.  A simple mechanism for subsetting
197input files associated with the extended domains has been implemented to avoid the need to
198maintain different sets of input fields for use with or without active ice cavities.  This
199subsetting operates for the j-direction only and works by optionally looking for and using
200a global file attribute (named: \np{open\_ocean\_jstart}) to determine the starting j-row
[11435]201for input.  The use of this option is best explained with an example:
[11339]202\medskip
[5118]203
[11339]204\noindent Consider an ORCA1
205configuration using the extended grid domain configuration file: \ifile{eORCA1\_domcfg.nc}
206This file define a horizontal domain of 362x332.  The first row with
[11552]207open ocean wet points in the non-isf bathymetry for this set is row 42 (\fortran\ indexing)
[11339]208then the formally correct setting for \np{open\_ocean\_jstart} is 41.  Using this value as
209the first row to be read will result in a 362x292 domain which is the same size as the
210original ORCA1 domain.  Thus the extended domain configuration file can be used with all
211the original input files for ORCA1 if the ice cavities are not active (\np{ln\_isfcav =
212.false.}).  Full instructions for achieving this are:
213
214\begin{itemize}
215\item  Add the new attribute to any input files requiring a j-row offset, i.e:
[11435]216\begin{cmds}
217ncatted  -a open_ocean_jstart,global,a,d,41 eORCA1_domcfg.nc
[11339]218\end{cmds}
219
[11435]220\item Add the logical switch \np{ln\_use\_jattr} to \nam{cfg} in the configuration
[11339]221namelist (if it is not already there) and set \np{.true.}
222\end{itemize}
223
224\noindent Note that with this option, the j-size of the global domain is (extended
225j-size minus \np{open\_ocean\_jstart} + 1 ) and this must match the \texttt{jpjglo} value
226for the configuration. This means an alternative version of \ifile{eORCA1\_domcfg.nc} must
227be created for when \np{ln\_use\_jattr} is active. The \texttt{ncap2} tool provides a
228convenient way of achieving this:
229
[9388]230\begin{cmds}
[11339]231ncap2 -s 'jpjglo=292' eORCA1_domcfg.nc nORCA1_domcfg.nc
[9388]232\end{cmds}
[10146]233
[11435]234The domain configuration file is unique in this respect since it also contains the value of \jp{jpjglo}
235that is read and used by the model.
236Any other global, 2D and 3D, netcdf, input field can be prepared for use in a reduced domain by adding the
237\texttt{open\_ocean\_jstart} attribute to the file's global attributes.
238In particular this is true for any field that is read by \NEMO\ using the following optional argument to
[11339]239the appropriate call to \np{iom\_get}.
[11435]240
[9388]241\begin{forlines}
[5118]242lrowattr=ln_use_jattr
[9388]243\end{forlines}
[5118]244
[11339]245Currently, only the domain configuration variables make use of this optional argument so
246this facility is of little practical use except for tests where no other external input
247files are needed or you wish to use an extended domain configuration with inputs from
248earlier, non-extended configurations. Alternatively, it should be possible to exclude
249empty rows for extended domain, forced ocean runs using interpolation on the fly, by
250adding the optional argument to \texttt{iom\_get} calls for the weights and initial
251conditions. Experimenting with this remains an exercise for the user.
[707]252
253% ================================================================
[2541]254% Accuracy and Reproducibility
255% ================================================================
[11571]256\section[Accuracy and reproducibility (\textit{lib\_fortran.F90})]{Accuracy and reproducibility (\protect\mdl{lib\_fortran})}
[9407]257\label{sec:MISC_fortran}
[2541]258
[11571]259\subsection[Issues with intrinsinc SIGN function (\texttt{\textbf{key\_nosignedzero}})]{Issues with intrinsinc SIGN function (\protect\key{nosignedzero})}
[9407]260\label{subsec:MISC_sign}
[2541]261
[11552]262The SIGN(A, B) is the \fortran\ intrinsic function delivers the magnitude of A with the sign of B.
[10354]263For example, SIGN(-3.0,2.0) has the value 3.0.
264The problematic case is when the second argument is zero, because, on platforms that support IEEE arithmetic,
265zero is actually a signed number.
[2541]266There is a positive zero and a negative zero.
267
[10442]268In \fninety, the processor was required always to deliver a positive result for SIGN(A, B) if B was zero.
269Nevertheless, in \fninety, the processor is allowed to do the correct thing and deliver ABS(A) when
[10354]270B is a positive zero and -ABS(A) when B is a negative zero.
271This change in the specification becomes apparent only when B is of type real, and is zero,
272and the processor is capable of distinguishing between positive and negative zero,
273and B is negative real zero.
[11552]274Then SIGN delivers a negative result where, under \fninety\ rules, it used to return a positive result.
[10354]275This change may be especially sensitive for the ice model,
276so we overwrite the intrinsinc function with our own function simply performing :   \\
[2541]277\verb?   IF( B >= 0.e0 ) THEN   ;   SIGN(A,B) = ABS(A)  ?    \\
278\verb?   ELSE                   ;   SIGN(A,B) =-ABS(A)     ?  \\
279\verb?   ENDIF    ? \\
[10354]280This feature can be found in \mdl{lib\_fortran} module and is effective when \key{nosignedzero} is defined.
281We use a CPP key as the overwritting of a intrinsic function can present performance issues with
282some computers/compilers.
[2541]283
284
285\subsection{MPP reproducibility}
[9407]286\label{subsec:MISC_glosum}
[2541]287
[10354]288The numerical reproducibility of simulations on distributed memory parallel computers is a critical issue.
[11435]289In particular, within \NEMO\ global summation of distributed arrays is most susceptible to rounding errors,
[10354]290and their propagation and accumulation cause uncertainty in final simulation reproducibility on
291different numbers of processors.
[11123]292To avoid so, based on \citet{he.ding_JS01} review of different technics,
[10354]293we use a so called self-compensated summation method.
[11435]294The idea is to estimate the roundoff error, store it in a buffer, and then add it back in the next addition.
[2541]295
[10354]296Suppose we need to calculate $b = a_1 + a_2 + a_3$.
297The following algorithm will allow to split the sum in two
298($sum_1 = a_{1} + a_{2}$ and $b = sum_2 = sum_1 + a_3$) with exactly the same rounding errors as
299the sum performed all at once.
[2541]300\begin{align*}
301   sum_1 \ \  &= a_1 + a_2 \\
302   error_1     &= a_2 + ( a_1 - sum_1 ) \\
303   sum_2 \ \  &= sum_1 + a_3 + error_1 \\
304   error_2     &= a_3 + error_1 + ( sum_1 - sum_2 ) \\
305   b \qquad \ &= sum_2 \\
306\end{align*}
[7646]307An example of this feature can be found in \mdl{lib\_fortran} module.
[10354]308It is systematicallt used in glob\_sum function (summation over the entire basin excluding duplicated rows and
309columns due to cyclic or north fold boundary condition as well as overlap MPP areas).
310The self-compensated summation method should be used in all summation in i- and/or j-direction.
311See \mdl{closea} module for an example.
[11435]312Note also that this implementation may be sensitive to the optimization level.
[2541]313
[3294]314\subsection{MPP scalability}
[9407]315\label{subsec:MISC_mppsca}
[2541]316
[10354]317The default method of communicating values across the north-fold in distributed memory applications (\key{mpp\_mpi})
318uses a \textsc{MPI\_ALLGATHER} function to exchange values from each processing region in
319the northern row with every other processing region in the northern row.
320This enables a global width array containing the top 4 rows to be collated on every northern row processor and then
321folded with a simple algorithm.
322Although conceptually simple, this "All to All" communication will hamper performance scalability for
323large numbers of northern row processors.
324From version 3.4 onwards an alternative method is available which only performs direct "Peer to Peer" communications
325between each processor and its immediate "neighbours" across the fold line.
326This is achieved by using the default \textsc{MPI\_ALLGATHER} method during initialisation to
327help identify the "active" neighbours.
328Stored lists of these neighbours are then used in all subsequent north-fold exchanges to
329restrict exchanges to those between associated regions.
330The collated global width array for each region is thus only partially filled but is guaranteed to
331be set at all the locations actually required by each individual for the fold operation.
332This alternative method should give identical results to the default \textsc{ALLGATHER} method and
333is recommended for large values of \np{jpni}.
[11435]334The new method is activated by setting \np{ln\_nnogather} to be true (\nam{mpp}).
[10354]335The reproducibility of results using the two methods should be confirmed for each new,
336non-reference configuration.
[3294]337
[2541]338% ================================================================
[707]339% Model optimisation, Control Print and Benchmark
340% ================================================================
[9393]341\section{Model optimisation, control print and benchmark}
[9407]342\label{sec:MISC_opt}
[1225]343%--------------------------------------------namctl-------------------------------------------------------
[10146]344
[11558]345\begin{listing}
346  \nlst{namctl}
[11567]347  \caption{\forcode{&namctl}}
[11558]348  \label{lst:namctl}
349\end{listing}
[707]350%--------------------------------------------------------------------------------------------------------------
351
[11435]352Options are defined through the  \nam{ctl} namelist variables.
[707]353
[10601]354\subsection{Vector optimisation}
[707]355
[10354]356\key{vectopt\_loop} enables the internal loops to collapse.
357This is very a very efficient way to increase the length of vector calculations and thus
[2282]358to speed up the model on vector computers.
[11435]359
[994]360% Add here also one word on NPROMA technique that has been found useless, since compiler have made significant progress during the last decade.
[11435]361
[994]362% Add also one word on NEC specific optimisation (Novercheck option for example)
[11435]363
[10601]364\subsection{Control print}
[707]365
[10601]366The \np{ln\_ctl} switch was originally used as a debugging option in two modes:
367
368\begin{enumerate}
369\item{\np{ln\_ctl}: compute and print the trends averaged over the interior domain in all TRA, DYN, LDF and
[10354]370ZDF modules.
[10601]371This option is very helpful when diagnosing the origin of an undesired change in model results. }
[707]372
[10601]373\item{also \np{ln\_ctl} but using the nictl and njctl namelist parameters to check the source of differences between
374mono and multi processor runs.}
375\end{enumerate}
[707]376
[10601]377However, in recent versions it has also been used to force all processors to assume the
378reporting role. Thus when \np{ln\_ctl} is true all processors produce their own versions
379of files such as: ocean.output, layout.dat, etc.  All such files, beyond the the normal
380reporting processor (narea == 1), are named with a \_XXXX extension to their name, where
381XXXX is a 4-digit area number (with leading zeros, if required). Other reporting files
382such as run.stat (and its netCDF counterpart: run.stat.nc) and tracer.stat contain global
383information and are only ever produced by the reporting master (narea == 1). For version
3844.0 a start has been made to return \np{ln\_ctl} to its original function by introducing
385a new control structure which allows finer control over which files are produced. This
386feature is still evolving but it does already allow the user to: select individually the
387production of run.stat and tracer.stat files and to toggle the production of other files
388on processors other than the reporting master. These other reporters can be a simple
389subset of processors as defined by a minimum, maximum and incremental processor number.
[707]390
[10601]391Note, that production of the run.stat and tracer.stat files require global communications.
392For run.stat, these are global min and max operations to find metrics such as the gloabl
393maximum velocity. For tracer.stat these are global sums of tracer fields. To improve model
394performance these operations are disabled by default and, where necessary, any use of the
395global values have been replaced with local calculations. For example, checks on the CFL
396criterion are now done on the local domain and only reported if a breach is detected.
[707]397
[10601]398Experienced users may wish to still monitor this information as a check on model progress.
399If so, the best compromise will be to activate the files with:
400
401\begin{verbatim}
402     sn_cfctl%l_config = .TRUE.
403       sn_cfctl%l_runstat = .TRUE.
404       sn_cfctl%l_trcstat = .TRUE.
405\end{verbatim}
406
407and to use the new time increment setting to ensure the values are collected and reported
408at a suitably long interval. For example:
409
[11435]410\begin{verbatim}
[10601]411       sn_cfctl%ptimincr  = 25
412\end{verbatim}
413
[11435]414will carry out the global communications and write the information every 25 timesteps. This
[10601]415increment also applies to the time.step file which is otherwise updated every timestep.
416
[707]417% ================================================================
[10414]418\biblio
419
[10442]420\pindex
421
[6997]422\end{document}
Note: See TracBrowser for help on using the repository browser.