Index: NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_misc.tex
===================================================================
--- NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_misc.tex	(revision 14197)
+++ NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_misc.tex	(revision 14644)
@@ -6,6 +6,4 @@
 \label{chap:MISC}
 
-\thispagestyle{plain}
-
 \chaptertoc
 
@@ -14,10 +12,11 @@
 {\footnotesize
   \begin{tabularx}{\textwidth}{l||X|X}
-    Release & Author(s) & Modifications \\
+    Release     & Author(s)            & Modifications                      \\
     \hline
-    {\em   4.0} & {\em ...} & {\em ...} \\
-    {\em   3.6} & {\em ...} & {\em ...} \\
-    {\em   3.4} & {\em ...} & {\em ...} \\
-    {\em <=3.4} & {\em ...} & {\em ...}
+    {\em   X.X} & {\em Pierre Mathiot} & {Update of the closed sea section} \\
+    {\em   4.0} & {\em ...           } & {\em ...                         } \\
+    {\em   3.6} & {\em ...           } & {\em ...                         } \\
+    {\em   3.4} & {\em ...           } & {\em ...                         } \\
+    {\em <=3.4} & {\em ...           } & {\em ...                         }
   \end{tabularx}
 }
@@ -109,21 +108,13 @@
 \end{figure}
 
-\begin{figure}[!tbp]
-  \centering
-  \includegraphics[width=0.66\textwidth]{MISC_closea_mask_example}
-  \caption[Mask fields for the \protect\mdl{closea} module]{
-    Example of mask fields for the \protect\mdl{closea} module.
-    \textit{Left}: a closea\_mask field;
-    \textit{Right}: a closea\_mask\_rnf field.
-    In this example, if \protect\np{ln_closea}{ln\_closea} is set to \forcode{.true.},
-    the mean freshwater flux over each of the American Great Lakes will be set to zero,
-    and the total residual for all the lakes, if negative, will be put into
-    the St Laurence Seaway in the area shown.}
-  \label{fig:MISC_closea_mask_example}
-\end{figure}
-
 %% =================================================================================================
 \section[Closed seas (\textit{closea.F90})]{Closed seas (\protect\mdl{closea})}
 \label{sec:MISC_closea}
+
+\begin{listing}
+  \nlst{namclo}
+  \caption{\forcode{&namclo}}
+  \label{lst:namclo}
+\end{listing}
 
 Some configurations include inland seas and lakes as ocean
@@ -138,53 +129,50 @@
 to zero and put the residual flux into the ocean.
 
-Prior to \NEMO\ 4 the locations of inland seas and lakes was set via
-hardcoded indices for various ORCA configurations. From \NEMO\ 4 onwards
-the inland seas and lakes are defined using mask fields in the
-domain configuration file. The options are as follows.
-
-\begin{enumerate}
-\item {{\bfseries No ``closea\_mask'' field is included in domain configuration
-  file.} In this case the closea module does nothing.}
-
-\item {{\bfseries A field called closea\_mask is included in the domain
-configuration file and ln\_closea=.false. in namelist namcfg.} In this
-case the inland seas defined by the closea\_mask field are filled in
-(turned to land points) at run time. That is every point in
-closea\_mask that is nonzero is set to be a land point.}
-
-\item {{\bfseries A field called closea\_mask is included in the domain
-configuration file and ln\_closea=.true. in namelist namcfg.} Each
-inland sea or group of inland seas is set to a positive integer value
-in the closea\_mask field (see \autoref{fig:MISC_closea_mask_example}
-for an example). The net surface flux over each inland sea or group of
+The inland seas and lakes are defined using mask fields in the
+domain configuration file. Special treatment of the closed sea (redistribution of net freshwater or mask those), are defined in \autoref{lst:namclo} and
+can be trigger by \np{ln_closea}{ln\_closea}\forcode{=.true.} in namelist namcfg.
+
+The options available are the following:
+\begin{description}
+\item[\np{ln_maskcs}{ln\_maskcs}\forcode{ = .true.}] All the closed seas are masked using \textit{mask\_opensea} variable.
+\item[\np{ln_maskcs}{ln\_maskcs}\forcode{ = .false.}] The net surface flux over each inland sea or group of
 inland seas is set to zero each timestep and the residual flux is
-distributed over the global ocean (ie. all ocean points where
-closea\_mask is zero).}
-
-\item {{\bfseries Fields called closea\_mask and closea\_mask\_rnf are
-included in the domain configuration file and ln\_closea=.true. in
-namelist namcfg.} This option works as for option 3, except that if
-the net surface flux over an inland sea is negative (net
-precipitation) it is put into the ocean at specified runoff points. A
-net positive surface flux (net evaporation) is still spread over the
-global ocean. The mapping from inland seas to runoff points is defined
-by the closea\_mask\_rnf field. Each mapping is defined by a positive
-integer value for the inland sea(s) and the corresponding runoff
-points. An example is given in
-\autoref{fig:MISC_closea_mask_example}. If no mapping is provided for a
-particular inland sea then the residual is spread over the global
-ocean.}
-
-\item {{\bfseries Fields called closea\_mask and closea\_mask\_emp are
-included in the domain configuration file and ln\_closea=.true. in
-namelist namcfg.} This option works the same as option 4 except that
-the nonzero net surface flux is sent to the ocean at the specified
-runoff points regardless of whether it is positive or negative. The
-mapping from inland seas to runoff points in this case is defined by
-the closea\_mask\_emp field.}
-\end{enumerate}
-
-There is a python routine to create the closea\_mask fields and append
-them to the domain configuration file in the utils/tools/DOMAINcfg directory.
+distributed over a target area.
+\end{description}
+
+When \np{ln_maskcs}{ln\_maskcs}\forcode{ = .false.}, 
+3 options are available for the redistribution (set up of these options is done in the tool DOMAINcfg):
+\begin{description}[font=$\bullet$ ]
+\item[ glo]: The residual flux is redistributed globally.
+\item[ emp]: The residual flux is redistributed as emp in a river outflow.
+\item[ rnf]: The residual flux is redistributed as rnf in a river outflow if negative. If there is a net evaporation, the residual flux is redistributed globally.
+\end{description}
+
+For each case, 2 masks are needed (\autoref{fig:MISC_closea_mask_example}): 
+\begin{description}
+\item $\bullet$ one describing the 'sources' (ie the closed seas concerned by each options) called \textit{mask\_csglo}, \textit{mask\_csrnf}, \textit{mask\_csemp}. 
+\item $\bullet$ one describing each group of inland seas (the Great Lakes for example) and the target area (river outflow or world ocean) for each group of inland seas (St Laurence for the Great Lakes for example) called
+\textit{mask\_csgrpglo}, \textit{mask\_csgrprnf}, \textit{mask\_csgrpemp}.
+\end{description}
+
+\begin{figure}[!tbp]
+  \centering
+  \includegraphics[width=0.66\textwidth]{MISC_closea_mask_example}
+  \caption[Mask fields for the \protect\mdl{closea} module]{
+    Example of mask fields for the \protect\mdl{closea} module.
+    \textit{Left}: a \textit{mask\_csrnf} field;
+    \textit{Right}: a \textit{mask\_csgrprnf} field.
+    In this example, if \protect\np{ln_closea}{ln\_closea} is set to \forcode{.true.},
+    the mean freshwater flux over each of the American Great Lakes will be set to zero,
+    and the total residual for all the lakes, if negative, will be put into
+    the St Laurence Seaway in the area shown.}
+  \label{fig:MISC_closea_mask_example}
+\end{figure}
+
+Closed sea not defined (because too small, issue in the bathymetry definition ...) are defined in \textit{mask\_csundef}.
+These points can be masked using the namelist option \np{ln_mask_csundef}{ln\_mask\_csundef}\forcode{= .true.} or used to correct the bathymetry input file.\\
+
+The masks needed for the closed sea can be created using the DOMAINcfg tool in the utils/tools/DOMAINcfg directory.
+See \autoref{sec:clocfg} for details on the usage of definition of the closed sea masks.
 
 %% =================================================================================================
@@ -205,5 +193,5 @@
 
 \noindent Consider an ORCA1
-configuration using the extended grid domain configuration file: \ifile{eORCA1\_domcfg.nc}
+configuration using the extended grid domain configuration file: \textit{eORCA1\_domcfg.nc}
 This file define a horizontal domain of 362x332.  The first row with
 open ocean wet points in the non-isf bathymetry for this set is row 42 (\fortran\ indexing)
@@ -226,5 +214,5 @@
 \noindent Note that with this option, the j-size of the global domain is (extended
 j-size minus \np{open_ocean_jstart}{open\_ocean\_jstart} + 1 ) and this must match the \texttt{jpjglo} value
-for the configuration. This means an alternative version of \ifile{eORCA1\_domcfg.nc} must
+for the configuration. This means an alternative version of \textit{eORCA1\_domcfg.nc} must
 be created for when \np{ln_use_jattr}{ln\_use\_jattr} is active. The \texttt{ncap2} tool provides a
 convenient way of achieving this:
@@ -234,5 +222,5 @@
 \end{cmds}
 
-The domain configuration file is unique in this respect since it also contains the value of \jp{jpjglo}
+The domain configuration file is unique in this respect since it also contains the value of \texttt{jpjglo}
 that is read and used by the model.
 Any other global, 2D and 3D, netcdf, input field can be prepared for use in a reduced domain by adding the
@@ -374,5 +362,5 @@
 
 When more information is required for monitoring or debugging purposes, the various
-forms of output can be selected via the \np{sn\_cfctl} structure. As well as simple
+forms of output can be selected via the \np{sn_cfctl}{sn\_cfctl} structure. As well as simple
 on-off switches this structure also allows selection of a range of processors for
 individual reporting (where appropriate) and a time-increment option to restrict
@@ -449,7 +437,5 @@
 systems so bug-hunting efforts using this facility should also utilise the \fortran:
 
-\begin{forlines} 
-   CALL FLUSH(numout)
-\end{forlines}
+\forline|CALL FLUSH(numout)|
 
 statement after any additional write statements to ensure that file contents reflect
@@ -482,18 +468,18 @@
 
 \begin{forlines}
-   sn_cfctl%l_glochk = .FALSE.    ! Range sanity checks are local (F) or global (T). Set T for debugging only
-   sn_cfctl%l_allon  = .FALSE.    ! IF T activate all options. If F deactivate all unless l_config is T
-     sn_cfctl%l_config = .TRUE.     ! IF .true. then control which reports are written with the following
-       sn_cfctl%l_runstat = .FALSE. ! switches and which areas produce reports with the proc integer settings.
-       sn_cfctl%l_trcstat = .FALSE. ! The default settings for the proc integers should ensure
-       sn_cfctl%l_oceout  = .FALSE. ! that  all areas report.
-       sn_cfctl%l_layout  = .FALSE. !
-       sn_cfctl%l_prtctl  = .FALSE. !
-       sn_cfctl%l_prttrc  = .FALSE. !
-       sn_cfctl%l_oasout  = .FALSE. !
-       sn_cfctl%procmin   = 0       ! Minimum area number for reporting [default:0]
-       sn_cfctl%procmax   = 1000000 ! Maximum area number for reporting [default:1000000]
-       sn_cfctl%procincr  = 1       ! Increment for optional subsetting of areas [default:1]
-       sn_cfctl%ptimincr  = 1       ! Timestep increment for writing time step progress info
+   sn_cfctl%l_glochk  = .false. ! Range sanity checks are local (F) or global (T). Set T for debugging only
+   sn_cfctl%l_allon   = .false. ! IF T activate all options. If F deactivate all unless l_config is T
+   sn_cfctl%l_config  = .true.  ! IF .true. then control which reports are written with the following
+   sn_cfctl%l_runstat = .false. ! switches and which areas produce reports with the proc integer settings.
+   sn_cfctl%l_trcstat = .false. ! The default settings for the proc integers should ensure
+   sn_cfctl%l_oceout  = .false. ! that  all areas report.
+   sn_cfctl%l_layout  = .false. !
+   sn_cfctl%l_prtctl  = .false. !
+   sn_cfctl%l_prttrc  = .false. !
+   sn_cfctl%l_oasout  = .false. !
+   sn_cfctl%procmin   = 0       ! Minimum area number for reporting [default:0]
+   sn_cfctl%procmax   = 1000000 ! Maximum area number for reporting [default:1000000]
+   sn_cfctl%procincr  = 1       ! Increment for optional subsetting of areas [default:1]
+   sn_cfctl%ptimincr  = 1       ! Timestep increment for writing time step progress info
 \end{forlines}
 
