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_DIA.tex in NEMO/trunk/doc/latex/NEMO/subfiles – NEMO

source: NEMO/trunk/doc/latex/NEMO/subfiles/chap_DIA.tex @ 11596

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

Application of some coding rules

  • Replace comments before sectioning cmds by a single line of 100 characters long to display when every line should break
  • Replace multi blank lines by one single blank line
  • For list environment, put \item, label and content on the same line
  • Remove \newpage and comments line around figure envs
  • Property svn:keywords set to Id
File size: 100.5 KB
Line 
1\documentclass[../main/NEMO_manual]{subfiles}
2
3\begin{document}
4\chapter{Output and Diagnostics (IOM, DIA, TRD, FLO)}
5\label{chap:DIA}
6
7\chaptertoc
8
9\vfill
10\begin{figure}[b]
11\subsubsection*{Changes record}
12\begin{tabular}{l||l|m{0.65\linewidth}}
13    Release   & Author        & Modifications \\
14    {\em 4.0} & {\em Mirek Andrejczuk, Massimiliano Drudi} & {\em }  \\
15    {\em }      & {\em Dorotea Iovino, Nicolas Martin} & {\em }  \\
16    {\em 3.6} & {\em Gurvan Madec, Sebastien Masson } & {\em }  \\
17    {\em 3.4} & {\em Gurvan Madec, Rachid Benshila, Andrew Coward } & {\em }  \\
18    {\em }      & {\em Christian Ethe, Sebastien Masson } & {\em }  \\
19\end{tabular}
20\end{figure}
21
22\section{Model output}
23\label{sec:DIA_io_old}
24
25The model outputs are of three types: the restart file, the output listing, and the diagnostic output file(s).
26The restart file is used internally by the code when the user wants to start the model with
27initial conditions defined by a previous simulation.
28It contains all the information that is necessary in order for there to be no changes in the model results
29(even at the computer precision) between a run performed with several restarts and
30the same run performed in one step.
31It should be noted that this requires that the restart file contains two consecutive time steps for
32all the prognostic variables.
33
34The output listing and file(s) are predefined but should be checked and eventually adapted to the user's needs.
35The output listing is stored in the \textit{ocean.output} file.
36The information is printed from within the code on the logical unit \texttt{numout}.
37To locate these prints, use the UNIX command "\textit{grep -i numout}" in the source code directory.
38
39By default, diagnostic output files are written in NetCDF format.
40Since version 3.2, when defining \key{iomput}, an I/O server has been added which
41provides more flexibility in the choice of the fields to be written as well as how
42the writing work is distributed over the processors in massively parallel computing.
43A complete description of the use of this I/O server is presented in the next section.
44
45%\gmcomment{                    % start of gmcomment
46
47\section{Standard model output (IOM)}
48\label{sec:DIA_iom}
49
50Since version 3.2, iomput is the \NEMO\ output interface of choice.
51It has been designed to be simple to use, flexible and efficient.
52The two main purposes of iomput are:
53
54\begin{enumerate}
55\item The complete and flexible control of the output files through external XML files adapted by
56  the user from standard templates.
57\item To achieve high performance and scalable output through the optional distribution of
58  all diagnostic output related tasks to dedicated processes.
59\end{enumerate}
60
61The first functionality allows the user to specify, without code changes or recompilation,
62aspects of the diagnostic output stream, such as:
63
64\begin{itemize}
65\item The choice of output frequencies that can be different for each file (including real months and years).
66\item The choice of file contents; includes complete flexibility over which data are written in which files
67  (the same data can be written in different files).
68\item The possibility to split output files at a chosen frequency.
69\item The possibility to extract a vertical or an horizontal subdomain.
70\item The choice of the temporal operation to perform, \eg: average, accumulate, instantaneous, min, max and once.
71\item Control over metadata via a large XML "database" of possible output fields.
72\end{itemize}
73
74In addition, iomput allows the user to add in the code the output of any new variable (scalar, 2D or 3D)
75in a very easy way.
76All details of iomput functionalities are listed in the following subsections.
77Examples of the XML files that control the outputs can be found in:
78\path{cfgs/ORCA2_ICE_PISCES/EXPREF/iodef.xml},
79\path{cfgs/SHARED/field_def_nemo-oce.xml},
80\path{cfgs/SHARED/field_def_nemo-pisces.xml},
81\path{cfgs/SHARED/field_def_nemo-ice.xml} and \path{cfgs/SHARED/domain_def_nemo.xml}. \\
82
83The second functionality targets output performance when running in parallel (\key{mpp\_mpi}).
84Iomput provides the possibility to specify N dedicated I/O processes (in addition to the \NEMO\ processes)
85to collect and write the outputs.
86With an appropriate choice of N by the user, the bottleneck associated with the writing of
87the output files can be greatly reduced.
88
89In version 3.6, the \rou{iom\_put} interface depends on
90an external code called \href{https://forge.ipsl.jussieu.fr/ioserver/browser/XIOS/branchs/xios-2.5}{XIOS-2.5}
91%(use of revision 618 or higher is required).
92This new IO server can take advantage of the parallel I/O functionality of NetCDF4 to
93create a single output file and therefore to bypass the rebuilding phase.
94Note that writing in parallel into the same NetCDF files requires that your NetCDF4 library is linked to
95an HDF5 library that has been correctly compiled (\ie\ with the configure option $--$enable-parallel).
96Note that the files created by iomput through XIOS are incompatible with NetCDF3.
97All post-processsing and visualization tools must therefore be compatible with NetCDF4 and not only NetCDF3.
98
99Even if not using the parallel I/O functionality of NetCDF4, using N dedicated I/O servers,
100where N is typically much less than the number of \NEMO\ processors, will reduce the number of output files created.
101This can greatly reduce the post-processing burden usually associated with using large numbers of \NEMO\ processors.
102Note that for smaller configurations, the rebuilding phase can be avoided,
103even without a parallel-enabled NetCDF4 library, simply by employing only one dedicated I/O server.
104
105\subsection{XIOS: Reading and writing restart file}
106
107XIOS may be used to read single file restart produced by \NEMO. Currently only the variables written to
108file \forcode{numror} can be handled by XIOS. To activate restart reading using XIOS, set \np[=.true. ]{ln_xios_read}{ln\_xios\_read}
109in \textit{namelist\_cfg}. This setting will be ignored when multiple restart files are present, and default \NEMO
110functionality will be used for reading. There is no need to change iodef.xml file to use XIOS to read
111restart, all definitions are done within the \NEMO\ code. For high resolution configuration, however,
112there may be a need to add the following line in iodef.xml (xios context):
113
114\begin{xmllines}
115<variable id="recv_field_timeout"        type="double">1800</variable>
116\end{xmllines}
117
118This variable sets timeout for reading.
119
120If XIOS is to be used to read restart from file generated with an earlier \NEMO\ version (3.6 for instance),
121dimension \forcode{z} defined in restart file must be renamed to \forcode{nav_lev}.\\
122
123XIOS can also be used to write \NEMO\ restart. A namelist parameter \np{nn_wxios}{nn\_wxios} is used to determine the
124type of restart \NEMO\ will write. If it is set to 0, default \NEMO\ functionality will be used - each
125processor writes its own restart file; if it is set to 1 XIOS will write restart into a single file;
126for \np[=2]{nn_wxios}{nn\_wxios} the restart will be written by XIOS into multiple files, one for each XIOS server.
127Note, however, that \textbf{\NEMO\ will not read restart generated by XIOS when \np[=2]{nn_wxios}{nn\_wxios}}. The restart will
128have to be rebuild before continuing the run. This option aims to reduce number of restart files generated by \NEMO\ only,
129and may be useful when there is a need to change number of processors used to run simulation.
130
131If an additional variable must be written to a restart file, the following steps are needed:
132\begin{description}
133   \item [step 1:] add variable name to a list of restart variables (in subroutine \rou{iom\_set\_rst\_vars,} \mdl{iom}) and
134define correct grid for the variable (\forcode{grid_N_3D} - 3D variable, \forcode{grid_N} - 2D variable, \forcode{grid_vector} -
1351D variable, \forcode{grid_scalar} - scalar),
136   \item [step 2:] add variable to the list of fields written by restart.  This can be done either in subroutine
137\rou{iom\_set\_rstw\_core} (\mdl{iom}) or by calling  \rou{iom\_set\_rstw\_active} (\mdl{iom}) with the name of a variable
138as an argument. This convention follows approach for writing restart using iom, where variables are
139written either by \rou{rst\_write} or by calling \rou{iom\_rstput} from individual routines.
140\end{description}
141
142An older versions of XIOS do not support reading functionality. It's recommended to use at least XIOS2@1451.
143
144\subsection{XIOS: XML Inputs-Outputs Server}
145
146\subsubsection{Attached or detached mode?}
147
148Iomput is based on \href{http://forge.ipsl.jussieu.fr/ioserver/wiki}{XIOS},
149the io\_server developed by Yann Meurdesoif from IPSL.
150The behaviour of the I/O subsystem is controlled by settings in the external XML files listed above.
151Key settings in the iodef.xml file are the tags associated with each defined file.
152
153\xmlline|<variable id="using_server" type="bool"></variable>|
154
155The \texttt{using\_server} setting determines whether or not the server will be used in
156\textit{attached mode}
157(as a library) [\texttt{> false <}] or in \textit{detached mode}
158(as an external executable on N additional, dedicated cpus) [\texttt{ > true <}].
159The \textit{attached mode} is simpler to use but much less efficient for
160massively parallel applications.
161The type of each file can be either ''multiple\_file'' or ''one\_file''.
162
163In \textit{attached mode} and if the type of file is ''multiple\_file'',
164then each \NEMO\ process will also act as an IO server and produce its own set of output files.
165Superficially, this emulates the standard behaviour in previous versions.
166However, the subdomain written out by each process does not correspond to
167the \forcode{jpi x jpj x jpk} domain actually computed by the process (although it may if \forcode{jpni=1}).
168Instead each process will have collected and written out a number of complete longitudinal strips.
169If the ''one\_file'' option is chosen then all processes will collect their longitudinal strips and
170write (in parallel) to a single output file.
171
172In \textit{detached mode} and if the type of file is ''multiple\_file'',
173then each stand-alone XIOS process will collect data for a range of complete longitudinal strips and
174write to its own set of output files.
175If the ''one\_file'' option is chosen then all XIOS processes will collect their longitudinal strips and
176write (in parallel) to a single output file.
177Note running in detached mode requires launching a Multiple Process Multiple Data (MPMD) parallel job.
178The following subsection provides a typical example but the syntax will vary in different MPP environments.
179
180\subsubsection{Number of cpu used by XIOS in detached mode}
181
182The number of cores used by the XIOS is specified when launching the model.
183The number of cores dedicated to XIOS should be from \texttildelow1/10 to \texttildelow1/50 of the number of
184cores dedicated to \NEMO.
185Some manufacturers suggest using O($\sqrt{N}$) dedicated IO processors for N processors but
186this is a general recommendation and not specific to \NEMO.
187It is difficult to provide precise recommendations because the optimal choice will depend on
188the particular hardware properties of the target system
189(parallel filesystem performance, available memory, memory bandwidth etc.)
190and the volume and frequency of data to be created.
191Here is an example of 2 cpus for the io\_server and 62 cpu for nemo using mpirun:
192\cmd|mpirun -np 62 ./nemo.exe : -np 2 ./xios_server.exe|
193
194\subsubsection{Control of XIOS: the context in iodef.xml}
195
196As well as the \texttt{using\_server} flag, other controls on the use of XIOS are set in
197the XIOS context in \textit{iodef.xml}.
198See the XML basics section below for more details on XML syntax and rules.
199
200\begin{table}
201  \begin{tabularx}{\textwidth}{|lXl|}
202    \hline
203    variable name                                                           &
204    description                                                             &
205    example  \\
206    \hline
207    \hline
208    buffer\_size                                                            &
209    buffer size used by XIOS to send data from \NEMO\ to XIOS.
210    Larger is more efficient.
211    Note that needed/used buffer sizes are summarized at the end of the job &
212    25000000 \\
213    \hline
214    buffer\_server\_factor\_size                                            &
215    ratio between \NEMO\ and XIOS buffer size.
216    Should be 2.                                                            &
217    2        \\
218    \hline
219    info\_level                                                             &
220    verbosity level (0 to 100)                                              &
221    0        \\
222    \hline
223    using\_server                                                           &
224    activate attached(false) or detached(true) mode                         &
225    true     \\
226    \hline
227    using\_oasis                                                            &
228    XIOS is used with OASIS(true) or not (false)                            &
229    false    \\
230    \hline
231    oasis\_codes\_id                                                        &
232    when using oasis, define the identifier of \NEMO\ in the namcouple.
233    Note that the identifier of XIOS is xios.x                              &
234    oceanx   \\
235    \hline
236  \end{tabularx}
237\end{table}
238
239\subsection{Practical issues}
240
241\subsubsection{Installation}
242
243As mentioned, XIOS is supported separately and must be downloaded and compiled before it can be used with \NEMO.
244See the installation guide on the \href{http://forge.ipsl.jussieu.fr/ioserver/wiki}{XIOS} wiki for help and guidance.
245\NEMO\ will need to link to the compiled XIOS library.
246The \href{https://forge.ipsl.jussieu.fr/nemo/chrome/site/doc/NEMO/guide/html/install.html#extract-and-install-xios}
247{Extract and install XIOS} guide provides an example illustration of how this can be achieved.
248
249\subsubsection{Add your own outputs}
250
251It is very easy to add your own outputs with iomput.
252Many standard fields and diagnostics are already prepared (\ie, steps 1 to 3 below have been done) and
253simply need to be activated by including the required output in a file definition in iodef.xml (step 4).
254To add new output variables, all 4 of the following steps must be taken.
255
256\begin{enumerate}
257\item [1.]
258  in \NEMO\ code, add a \forcode{CALL iom_put( 'identifier', array )} where you want to output a 2D or 3D array.
259\item [2.]
260  If necessary, add \forcode{USE iom ! I/O manager library} to the list of used modules in
261  the upper part of your module.
262\item [3.]
263  in the field\_def.xml file, add the definition of your variable using the same identifier you used in the f90 code
264  (see subsequent sections for a details of the XML syntax and rules).
265  For example:
266
267\begin{xmllines}
268<field_definition>
269   <field_group id="grid_T" grid_ref="grid_T_3D"> <!-- T grid -->
270   ...
271      <field id="identifier" long_name="blabla" ... />
272      ...
273</field_definition>
274\end{xmllines}
275
276Note your definition must be added to the field\_group whose reference grid is consistent with the size of
277the array passed to iomput.
278The grid\_ref attribute refers to definitions set in iodef.xml which, in turn,
279reference grids and axes either defined in the code
280(iom\_set\_domain\_attr and iom\_set\_axis\_attr in \mdl{iom}) or defined in the domain\_def.xml file.
281\eg:
282
283\begin{xmllines}
284<grid id="grid_T_3D" domain_ref="grid_T" axis_ref="deptht"/>
285\end{xmllines}
286
287Note, if your array is computed within the surface module each \np{nn_fsbc}{nn\_fsbc} time\_step,
288add the field definition within the field\_group defined with the id "SBC":
289\xmlcode{<field_group id="SBC" ...>} which has been defined with the correct frequency of operations
290(iom\_set\_field\_attr in \mdl{iom})
291\item [4.]
292  add your field in one of the output files defined in iodef.xml
293  (again see subsequent sections for syntax and rules)
294
295\begin{xmllines}
296<file id="file1" .../>
297...
298   <field field_ref="identifier" />
299   ...
300</file>
301\end{xmllines}
302
303\end{enumerate}
304
305\subsection{XML fundamentals}
306
307\subsubsection{ XML basic rules}
308
309XML tags begin with the less-than character ("$<$") and end with the greater-than character ("$>$").
310You use tags to mark the start and end of elements, which are the logical units of information in an XML document.
311In addition to marking the beginning of an element, XML start tags also provide a place to specify attributes.
312An attribute specifies a single property for an element, using a name/value pair, for example:
313\xmlcode{<a b="x" c="y" d="z"> ... </a>}.
314See \href{http://www.xmlnews.org/docs/xml-basics.html}{here} for more details.
315
316\subsubsection{Structure of the XML file used in \NEMO}
317
318The XML file used in XIOS is structured by 7 families of tags:
319context, axis, domain, grid, field, file and variable.
320Each tag family has hierarchy of three flavors (except for context):
321
322\begin{table}
323  \begin{tabular*}{\textwidth}{|p{0.15\textwidth}p{0.4\textwidth}p{0.35\textwidth}|}
324    \hline
325    flavor  & description                                                                 &
326                                                                                            example                          \\
327    \hline
328    \hline
329    root    & declaration of the root element that can contain element groups or elements &
330                                                                                            \xmlcode{<file_definition ... >} \\
331    \hline
332    group   & declaration of a group element that can contain element groups or elements  &
333                                                                                            \xmlcode{<file_group      ... >} \\
334    \hline
335    element & declaration of an element that can contain elements                         &
336                                                                                            \xmlcode{<file            ... >} \\
337    \hline
338  \end{tabular*}
339\end{table}
340
341Each element may have several attributes.
342Some attributes are mandatory, other are optional but have a default value and other are completely optional.
343Id is a special attribute used to identify an element or a group of elements.
344It must be unique for a kind of element.
345It is optional, but no reference to the corresponding element can be done if it is not defined.
346
347The XML file is split into context tags that are used to isolate IO definition from
348different codes or different parts of a code.
349No interference is possible between 2 different contexts.
350Each context has its own calendar and an associated timestep.
351In \NEMO, we used the following contexts (that can be defined in any order):
352
353\begin{table}
354  \begin{tabular}{|p{0.15\textwidth}p{0.4\textwidth}p{0.35\textwidth}|}
355    \hline
356    context         &   description                                                                &
357                                                                                                     example                              \\
358    \hline
359    \hline
360    context xios    &   context containing information for XIOS                                    &
361                                                                                                     \xmlcode{<context id="xios" ... >}   \\
362    \hline
363    context nemo    &   context containing IO information for \NEMO\ (mother grid when using AGRIF)  &
364                                                                                                     \xmlcode{<context id="nemo" ... >}   \\
365    \hline
366    context 1\_nemo &   context containing IO information for \NEMO\ child grid 1 (when using AGRIF) &
367                                                                                                     \xmlcode{<context id="1_nemo" ... >} \\
368    \hline
369    context n\_nemo &   context containing IO information for \NEMO\ child grid n (when using AGRIF) &
370                                                                                                     \xmlcode{<context id="n_nemo" ... >} \\
371    \hline
372  \end{tabular}
373\end{table}
374
375\noindent The xios context contains only 1 tag:
376
377\begin{table}
378  \begin{tabular}{|p{0.15\textwidth}p{0.4\textwidth}p{0.35\textwidth}|}
379    \hline
380    context tag                                      &
381                                                       description                                      &
382                                                                                                          example                              \\
383    \hline
384    \hline
385    variable\_definition                             &
386                                                       define variables needed by XIOS.
387                                                       This can be seen as a kind of namelist for XIOS. &
388                                                                                                          \xmlcode{<variable_definition ... >} \\
389    \hline
390   \end{tabular}
391\end{table}
392
393\noindent Each context tag related to \NEMO\ (mother or child grids) is divided into 5 parts
394(that can be defined in any order):
395
396\begin{table}
397  \begin{tabular}{|p{0.15\textwidth}p{0.4\textwidth}p{0.35\textwidth}|}
398    \hline
399    context tag        &   description                                                               &
400                                                                                                       example                            \\
401    \hline
402    \hline
403    field\_definition  &   define all variables that can potentially be outputted                    &
404                                                                                                       \xmlcode{<field_definition ... >}  \\
405    \hline
406    file\_definition   &   define the netcdf files to be created and the variables they will contain &
407                                                                                                       \xmlcode{<file_definition ... >}   \\
408    \hline
409    axis\_definition   &   define vertical axis                                                      &
410                                                                                                       \xmlcode{<axis_definition ... >}   \\
411    \hline
412    domain\_definition &   define the horizontal grids                                               &
413                                                                                                       \xmlcode{<domain_definition ... >} \\
414    \hline
415    grid\_definition   &   define the 2D and 3D grids (association of an axis and a domain)          &
416                                                                                                       \xmlcode{<grid_definition ... >}   \\
417    \hline
418  \end{tabular}
419\end{table}
420
421\subsubsection{Nesting XML files}
422
423The XML file can be split in different parts to improve its readability and facilitate its use.
424The inclusion of XML files into the main XML file can be done through the attribute src:
425\xmlline|<context src="./nemo_def.xml" />|
426
427\noindent In \NEMO, by default, the field definition is done in 3 separate files (
428\path{cfgs/SHARED/field_def_nemo-oce.xml},
429\path{cfgs/SHARED/field_def_nemo-pisces.xml} and
430\path{cfgs/SHARED/field_def_nemo-ice.xml} ) and the  domain definition is done in another file ( \path{cfgs/SHARED/domain_def_nemo.xml} )
431that
432are included in the main iodef.xml file through the following commands:
433\begin{xmllines}
434<context id="nemo" src="./context_nemo.xml"/>
435\end{xmllines}
436
437\subsubsection{Use of inheritance}
438
439XML extensively uses the concept of inheritance.
440XML has a tree based structure with a parent-child oriented relation: all children inherit attributes from parent,
441but an attribute defined in a child replace the inherited attribute value.
442Note that the special attribute ''id'' is never inherited.
443\\
444\\
445example 1: Direct inheritance.
446
447\begin{xmllines}
448<field_definition operation="average" >
449   <field id="sst"                    />   <!-- averaged      sst -->
450   <field id="sss" operation="instant"/>   <!-- instantaneous sss -->
451</field_definition>
452\end{xmllines}
453
454The field ''sst'' which is part (or a child) of the field\_definition will inherit the value ''average'' of
455the attribute ''operation'' from its parent.
456Note that a child can overwrite the attribute definition inherited from its parents.
457In the example above, the field ''sss'' will for example output instantaneous values instead of average values.
458\\
459\\
460example 2: Inheritance by reference.
461
462\begin{xmllines}
463<field_definition>
464   <field id="sst" long_name="sea surface temperature" />
465   <field id="sss" long_name="sea surface salinity"    />
466</field_definition>
467<file_definition>
468   <file id="myfile" output_freq="1d" />
469      <field field_ref="sst"                            />  <!-- default def -->
470      <field field_ref="sss" long_name="my description" />  <!-- overwrite   -->
471   </file>
472</file_definition>
473\end{xmllines}
474
475Inherit (and overwrite, if needed) the attributes of a tag you are refering to.
476
477\subsubsection{Use of groups}
478
479Groups can be used for 2 purposes.
480Firstly, the group can be used to define common attributes to be shared by the elements of
481the group through inheritance.
482In the following example, we define a group of field that will share a common grid ''grid\_T\_2D''.
483Note that for the field ''toce'', we overwrite the grid definition inherited from the group by ''grid\_T\_3D''.
484
485\begin{xmllines}
486<field_group id="grid_T" grid_ref="grid_T_2D">
487   <field id="toce" long_name="temperature"             unit="degC" grid_ref="grid_T_3D"/>
488   <field id="sst"  long_name="sea surface temperature" unit="degC"                     />
489   <field id="sss"  long_name="sea surface salinity"    unit="psu"                      />
490   <field id="ssh"  long_name="sea surface height"      unit="m"                        />
491   ...
492\end{xmllines}
493
494Secondly, the group can be used to replace a list of elements.
495Several examples of groups of fields are proposed at the end of the XML field files (
496\path{cfgs/SHARED/field_def_nemo-oce.xml},
497\path{cfgs/SHARED/field_def_nemo-pisces.xml} and
498\path{cfgs/SHARED/field_def_nemo-ice.xml} ) .
499For example, a short list of the usual variables related to the U grid:
500
501\begin{xmllines}
502<field_group id="groupU" >
503   <field field_ref="uoce"  />
504   <field field_ref="ssu" />
505   <field field_ref="utau"  />
506</field_group>
507\end{xmllines}
508
509that can be directly included in a file through the following syntax:
510
511\begin{xmllines}
512<file id="myfile_U" output_freq="1d" />
513   <field_group group_ref="groupU" />
514   <field field_ref="uocetr_eff"   />  <!-- add another field -->
515</file>
516\end{xmllines}
517
518\subsection{Detailed functionalities}
519
520The file \path{NEMOGCM/CONFIG/ORCA2_LIM/iodef_demo.xml} provides several examples of the use of
521the new functionalities offered by the XML interface of XIOS.
522
523\subsubsection{Define horizontal subdomains}
524
525Horizontal subdomains are defined through the attributs zoom\_ibegin, zoom\_jbegin, zoom\_ni, zoom\_nj of
526the tag family domain.
527It must therefore be done in the domain part of the XML file.
528For example, in \path{cfgs/SHARED/domain_def.xml}, we provide the following example of a definition of
529a 5 by 5 box with the bottom left corner at point (10,10).
530
531\begin{xmllines}
532<domain id="myzoomT" domain_ref="grid_T">
533   <zoom_domain ibegin="10" jbegin="10" ni="5" nj="5" />
534\end{xmllines}
535
536The use of this subdomain is done through the redefinition of the attribute domain\_ref of the tag family field.
537For example:
538
539\begin{xmllines}
540<file id="myfile_vzoom" output_freq="1d" >
541   <field field_ref="toce" domain_ref="myzoomT"/>
542</file>
543\end{xmllines}
544
545Moorings are seen as an extrem case corresponding to a 1 by 1 subdomain.
546The Equatorial section, the TAO, RAMA and PIRATA moorings are already registered in the code and
547can therefore be outputted without taking care of their (i,j) position in the grid.
548These predefined domains can be activated by the use of specific domain\_ref:
549''EqT'', ''EqU'' or ''EqW'' for the equatorial sections and
550the mooring position for TAO, RAMA and PIRATA followed by ''T'' (for example: ''8s137eT'', ''1.5s80.5eT'' ...)
551
552\begin{xmllines}
553<file id="myfile_vzoom" output_freq="1d" >
554   <field field_ref="toce" domain_ref="0n180wT"/>
555</file>
556\end{xmllines}
557
558Note that if the domain decomposition used in XIOS cuts the subdomain in several parts and if
559you use the ''multiple\_file'' type for your output files,
560you will endup with several files you will need to rebuild using unprovided tools (like ncpdq and ncrcat,
561\href{http://nco.sourceforge.net/nco.html#Concatenation}{see nco manual}).
562We are therefore advising to use the ''one\_file'' type in this case.
563
564\subsubsection{Define vertical zooms}
565
566Vertical zooms are defined through the attributs zoom\_begin and zoom\_n of the tag family axis.
567It must therefore be done in the axis part of the XML file.
568For example, in \path{cfgs/ORCA2_ICE_PISCES/EXPREF/iodef_demo.xml}, we provide the following example:
569
570\begin{xmllines}
571<axis_definition>
572   <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
573   <axis id="deptht_zoom" azix_ref="deptht" >
574      <zoom_axis zoom_begin="1" zoom_n="10" />
575   </axis>
576\end{xmllines}
577
578The use of this vertical zoom is done through the redefinition of the attribute axis\_ref of the tag family field.
579For example:
580
581\begin{xmllines}
582<file id="myfile_hzoom" output_freq="1d" >
583   <field field_ref="toce" axis_ref="deptht_myzoom"/>
584</file>
585\end{xmllines}
586
587\subsubsection{Control of the output file names}
588
589The output file names are defined by the attributs ''name'' and ''name\_suffix'' of the tag family file.
590For example:
591
592\begin{xmllines}
593<file_group id="1d" output_freq="1d" name="myfile_1d" >
594   <file id="myfileA" name_suffix="_AAA" > <!-- will create file "myfile_1d_AAA"  -->
595      ...
596   </file>
597   <file id="myfileB" name_suffix="_BBB" > <!-- will create file "myfile_1d_BBB" -->
598      ...
599   </file>
600</file_group>
601\end{xmllines}
602
603However it is often very convienent to define the file name with the name of the experiment,
604the output file frequency and the date of the beginning and the end of the simulation
605(which are informations stored either in the namelist or in the XML file).
606To do so, we added the following rule:
607if the id of the tag file is ''fileN'' (where N = 1 to 999 on 1 to 3 digits) or
608one of the predefined sections or moorings (see next subsection),
609the following part of the name and the name\_suffix (that can be inherited) will be automatically replaced by:
610
611\begin{table}
612  \begin{tabularx}{\textwidth}{|lX|}
613    \hline
614    \centering placeholder string &
615    automatically replaced by                          \\
616    \hline
617    \hline
618    \centering @expname@          &
619    the experiment name (from cn\_exp in the namelist) \\
620    \hline
621    \centering @freq@             &
622    output frequency (from attribute output\_freq)     \\
623    \hline
624    \centering @startdate@        &
625    starting date of the simulation (from nn\_date0 in the restart or the namelist).
626    \newline
627    \verb?yyyymmdd?          format                   \\
628    \hline
629    \centering @startdatefull@    &
630    starting date of the simulation (from nn\_date0 in the restart or the namelist).
631    \newline
632    \verb?yyyymmdd_hh:mm:ss? format                    \\
633    \hline
634    \centering @enddate@          &
635    ending date of the simulation   (from nn\_date0 and nn\_itend  in the namelist).
636    \newline
637    \verb?yyyymmdd?          format                    \\
638    \hline
639    \centering @enddatefull@      &
640    ending date of the simulation   (from nn\_date0 and nn\_itend  in the namelist).
641    \newline
642    \verb?yyyymmdd_hh:mm:ss? format                    \\
643    \hline
644  \end{tabularx}
645\end{table}
646
647\noindent For example,
648\xmlline|<file id="myfile_hzoom" name="myfile_@expname@_@startdate@_freq@freq@" output_freq="1d" >|
649
650\noindent with the namelist:
651\begin{forlines}
652cn_exp    = "ORCA2"
653nn_date0  = 19891231
654ln_rstart = .false.
655\end{forlines}
656
657\noindent will give the following file name radical: \ifile{myfile\_ORCA2\_19891231\_freq1d}
658
659\subsubsection{Other controls of the XML attributes from \NEMO}
660
661The values of some attributes are defined by subroutine calls within \NEMO
662(calls to iom\_set\_domain\_attr, iom\_set\_axis\_attr and iom\_set\_field\_attr in \mdl{iom}).
663Any definition given in the XML file will be overwritten.
664By convention, these attributes are defined to ''auto'' (for string) or ''0000'' (for integer) in the XML file
665(but this is not necessary).
666\\
667
668Here is the list of these attributes:
669\\
670
671\begin{table}
672  \begin{tabular}{|l|c|c|}
673    \hline
674    tag ids affected by automatic definition of some of their attributes &
675    name attribute                                                       &
676    attribute value                                                      \\
677    \hline
678    \hline
679    field\_definition                                                    &
680    freq\_op                                                             &
681    \np{rn_rdt}{rn\_rdt}                                                         \\
682    \hline
683    SBC                                                                  &
684    freq\_op                                                             &
685    \np{rn_rdt}{rn\_rdt} $\times$ \np{nn_fsbc}{nn\_fsbc}                                  \\
686    \hline
687    ptrc\_T                                                              &
688    freq\_op                                                             &
689    \np{rn_rdt}{rn\_rdt} $\times$ \np{nn_dttrc}{nn\_dttrc}                                 \\
690    \hline
691    diad\_T                                                              &
692    freq\_op                                                             &
693    \np{rn_rdt}{rn\_rdt} $\times$ \np{nn_dttrc}{nn\_dttrc}                                 \\
694    \hline
695    EqT, EqU, EqW                                                        &
696    jbegin, ni,                                                          &
697    according to the grid                                                \\
698                                                                         &
699    name\_suffix                                                         &
700                                                                         \\
701    \hline
702    TAO, RAMA and PIRATA moorings                                        &
703    zoom\_ibegin, zoom\_jbegin,                                          &
704    according to the grid                                                \\
705                                                                         &
706    name\_suffix                                                         &
707                                                                         \\
708    \hline
709  \end{tabular}
710\end{table}
711
712\subsubsection{Advanced use of XIOS functionalities}
713
714\subsection{XML reference tables}
715\label{subsec:DIA_IOM_xmlref}
716
717\begin{enumerate}
718\item Simple computation: directly define the computation when refering to the variable in the file definition.
719
720\begin{xmllines}
721<field field_ref="sst"  name="tosK"  unit="degK" > sst + 273.15 </field>
722<field field_ref="taum" name="taum2" unit="N2/m4" long_name="square of wind stress module" > taum * taum </field>
723<field field_ref="qt"   name="stupid_check" > qt - qsr - qns </field>
724\end{xmllines}
725
726\item Simple computation: define a new variable and use it in the file definition.
727
728in field\_definition:
729
730\begin{xmllines}
731<field id="sst2" long_name="square of sea surface temperature" unit="degC2" >  sst * sst </field >
732\end{xmllines}
733
734in file\_definition:
735
736\begin{xmllines}
737<field field_ref="sst2" > sst2 </field>
738\end{xmllines}
739
740Note that in this case, the following syntaxe \xmlcode{<field field_ref="sst2" />} is not working as
741sst2 won't be evaluated.
742
743\item Change of variable precision:
744
745\begin{xmllines}
746<!-- force to keep real 8 -->
747<field field_ref="sst" name="tos_r8" prec="8" />
748<!-- integer 2  with add_offset and scale_factor attributes -->
749<field field_ref="sss" name="sos_i2" prec="2" add_offset="20." scale_factor="1.e-3" />
750\end{xmllines}
751
752Note that, then the code is crashing, writting real4 variables forces a numerical conversion from
753real8 to real4 which will create an internal error in NetCDF and will avoid the creation of the output files.
754Forcing double precision outputs with prec="8" (for example in the field\_definition) will avoid this problem.
755
756\item add user defined attributes:
757
758\begin{xmllines}
759<file_group id="1d" output_freq="1d" output_level="10" enabled=".true."> <!-- 1d files -->
760   <file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
761      <field field_ref="sst" name="tos" >
762         <variable id="my_attribute1" type="string"  > blabla </variable>
763         <variable id="my_attribute2" type="integer" > 3      </variable>
764         <variable id="my_attribute3" type="float"   > 5.0    </variable>
765      </field>
766      <variable id="my_global_attribute" type="string" > blabla_global </variable>
767   </file>
768</file_group>
769\end{xmllines}
770
771\item use of the ``@'' function: example 1, weighted temporal average
772
773 - define a new variable in field\_definition
774
775\begin{xmllines}
776<field id="toce_e3t" long_name="temperature * e3t" unit="degC*m" grid_ref="grid_T_3D" >toce * e3t</field>
777\end{xmllines}
778
779 - use it when defining your file.
780
781\begin{xmllines}
782<file_group id="5d" output_freq="5d"  output_level="10" enabled=".true." >  <!-- 5d files -->
783   <file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
784      <field field_ref="toce" operation="instant" freq_op="5d" > @toce_e3t / @e3t </field>
785   </file>
786</file_group>
787\end{xmllines}
788
789The freq\_op="5d" attribute is used to define the operation frequency of the ``@'' function: here 5 day.
790The temporal operation done by the ``@'' is the one defined in the field definition:
791here we use the default, average.
792So, in the above case, @toce\_e3t will do the 5-day mean of toce*e3t.
793Operation="instant" refers to the temporal operation to be performed on the field''@toce\_e3t / @e3t'':
794here the temporal average is alreday done by the ``@'' function so we just use instant to do the ratio of
795the 2 mean values.
796field\_ref="toce" means that attributes not explicitely defined, are inherited from toce field.
797Note that in this case, freq\_op must be equal to the file output\_freq.
798
799\item use of the ``@'' function: example 2, monthly SSH standard deviation
800
801 - define a new variable in field\_definition
802
803\begin{xmllines}
804<field id="ssh2" long_name="square of sea surface temperature" unit="degC2" > ssh * ssh </field >
805\end{xmllines}
806
807 - use it when defining your file.
808
809\begin{xmllines}
810<file_group id="1m" output_freq="1m"  output_level="10" enabled=".true." >  <!-- 1m files -->
811   <file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
812      <field field_ref="ssh" name="sshstd" long_name="sea_surface_temperature_standard_deviation"
813      operation="instant" freq_op="1m" >
814         sqrt( @ssh2 - @ssh * @ssh )
815      </field>
816   </file>
817</file_group>
818\end{xmllines}
819
820The freq\_op="1m" attribute is used to define the operation frequency of the ``@'' function: here 1 month.
821The temporal operation done by the ``@'' is the one defined in the field definition:
822here we use the default, average.
823So, in the above case, @ssh2 will do the monthly mean of ssh*ssh.
824Operation="instant" refers to the temporal operation to be performed on the field ''sqrt( @ssh2 - @ssh * @ssh )'':
825here the temporal average is alreday done by the ``@'' function so we just use instant.
826field\_ref="ssh" means that attributes not explicitely defined, are inherited from ssh field.
827Note that in this case, freq\_op must be equal to the file output\_freq.
828
829\item use of the ``@'' function: example 3, monthly average of SST diurnal cycle
830
831 - define 2 new variables in field\_definition
832
833\begin{xmllines}
834<field id="sstmax" field_ref="sst" long_name="max of sea surface temperature" operation="maximum" />
835<field id="sstmin" field_ref="sst" long_name="min of sea surface temperature" operation="minimum" />
836\end{xmllines}
837
838 - use these 2 new variables when defining your file.
839
840\begin{xmllines}
841<file_group id="1m" output_freq="1m"  output_level="10" enabled=".true." >  <!-- 1m files -->
842   <file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
843      <field field_ref="sst" name="sstdcy" long_name="amplitude of sst diurnal cycle" operation="average" freq_op="1d" >
844         @sstmax - @sstmin
845      </field>
846   </file>
847</file_group>
848\end{xmllines}
849
850\end{enumerate}
851
852The freq\_op="1d" attribute is used to define the operation frequency of the ``@'' function: here 1 day.
853The temporal operation done by the ``@'' is the one defined in the field definition:
854here maximum for sstmax and minimum for sstmin.
855So, in the above case, @sstmax will do the daily max and @sstmin the daily min.
856Operation="average" refers to the temporal operation to be performed on the field ``@sstmax - @sstmin'':
857here monthly mean (of daily max - daily min of the sst).
858field\_ref="sst" means that attributes not explicitely defined, are inherited from sst field.
859
860\subsubsection{Tag list per family}
861
862\begin{table}
863  \begin{tabularx}{\textwidth}{|l|X|X|l|X|}
864    \hline
865    tag name                                                                                     &
866    description                                                                                  &
867    accepted attribute                                                                           &
868    child of                                                                                     &
869    parent of                       \\
870    \hline
871    \hline
872    simulation                                                                                   &
873    this tag is the root tag which encapsulates all the content of the XML file                  &
874    none                                                                                         &
875    none                                                                                         &
876    context                         \\
877    \hline
878    context                                                                                      &
879    encapsulates parts of the XML file dedicated to different codes or different parts of a code &
880    id (''xios'', ''nemo'' or ''n\_nemo'' for the nth AGRIF zoom), src, time\_origin             &
881    simulation                                                                                   &
882    all root tags: ... \_definition \\
883    \hline
884  \end{tabularx}
885  \caption{XIOS: context tags}
886\end{table}
887
888\begin{table}
889  \begin{tabularx}{\textwidth}{|l|X|X|X|l|}
890    \hline
891    tag name                                                                                &
892    description                                                                             &
893    accepted attribute                                                                      &
894    child of                                                                                &
895    parent of             \\
896    \hline
897    \hline
898    field\_definition                                                                       &
899    encapsulates the definition of all the fields that can potentially be outputted         &
900    axis\_ref, default\_value, domain\_ref, enabled, grid\_ref, level, operation, prec, src &
901    context                                                                                 &
902    field or field\_group \\
903    \hline
904    field\_group                                                                            &
905    encapsulates a group of fields                                                          &
906    axis\_ref, default\_value, domain\_ref, enabled, group\_ref, grid\_ref,
907    id, level, operation, prec, src                                                         &
908    field\_definition, field\_group, file                                                   &
909    field or field\_group \\
910    \hline
911    field                                                                                   &
912    define a specific field                                                                 &
913    axis\_ref, default\_value, domain\_ref, enabled, field\_ref, grid\_ref,
914    id, level, long\_name, name, operation, prec, standard\_name, unit                      &
915    field\_definition, field\_group, file                                                   &
916    none                  \\
917    \hline
918  \end{tabularx}
919  \caption{XIOS: field tags ("\texttt{field\_*}")}
920\end{table}
921
922\begin{table}
923  \begin{tabularx}{\textwidth}{|l|X|X|X|l|}
924    \hline
925    tag name                                                            &
926    description                                                         &
927    accepted attribute                                                  &
928    child of                                                            &
929    parent of           \\
930    \hline
931    \hline
932    file\_definition                                                    &
933    encapsulates the definition of all the files that will be outputted &
934    enabled, min\_digits, name, name\_suffix, output\_level,
935    split\_freq\_format, split\_freq, sync\_freq, type, src             &
936    context                                                             &
937    file or file\_group \\
938    \hline
939    file\_group                                                         &
940    encapsulates a group of files that will be outputted                &
941    enabled, description, id, min\_digits, name, name\_suffix, output\_freq, output\_level,
942    split\_freq\_format, split\_freq, sync\_freq, type, src             &
943    file\_definition, file\_group                                       &
944    file or file\_group \\
945    \hline
946    file                                                                &
947    define the contents of a file to be outputted                       &
948    enabled, description, id, min\_digits, name, name\_suffix, output\_freq, output\_level,
949    split\_freq\_format, split\_freq, sync\_freq, type, src             &
950    file\_definition, file\_group                                       &
951    field               \\
952    \hline
953  \end{tabularx}
954  \caption{XIOS: file tags ("\texttt{file\_*}")}
955\end{table}
956
957\begin{table}
958  \begin{tabularx}{\textwidth}{|l|X|X|X|X|}
959    \hline
960    tag name                                                                               &
961    description                                                                            &
962    accepted attribute                                                                     &
963    child of                                                                               &
964    parent of         \\
965    \hline
966    \hline
967    axis\_definition                                                                       &
968    define all the vertical axis potentially used by the variables                         &
969    src                                                                                    &
970    context                                                                                &
971    axis\_group, axis \\
972    \hline
973    axis\_group                                                                            &
974    encapsulates a group of vertical axis                                                  &
975    id, lon\_name, positive, src, standard\_name, unit, zoom\_begin, zoom\_end, zoom\_size &
976    axis\_definition, axis\_group                                                          &
977    axis\_group, axis \\
978    \hline
979    axis                                                                                   &
980    define a vertical axis                                                                 &
981    id, lon\_name, positive, src, standard\_name, unit, zoom\_begin, zoom\_end, zoom\_size &
982    axis\_definition, axis\_group                                                          &
983    none             \\
984    \hline
985  \end{tabularx}
986  \caption{XIOS: axis tags ("\texttt{axis\_*}")}
987\end{table}
988
989\begin{table}
990  \begin{tabularx}{\textwidth}{|l|X|X|X|X|}
991    \hline
992    tag name                                                            &
993    description                                                         &
994    accepted attribute                                                  &
995    child of                                                            &
996    parent of               \\
997    \hline
998    \hline
999    domain\_\-definition                                                &
1000    define all the horizontal domains potentially used by the variables &
1001    src                                                                 &
1002    context                                                             &
1003    domain\_\-group, domain \\
1004    \hline
1005    domain\_group                                                       &
1006    encapsulates a group of horizontal domains                          &
1007    id, lon\_name, src, zoom\_ibegin, zoom\_jbegin, zoom\_ni, zoom\_nj  &
1008    domain\_\-definition, domain\_group                                 &
1009    domain\_\-group, domain \\
1010    \hline
1011    domain                                                              &
1012    define an horizontal domain                                         &
1013    id, lon\_name, src, zoom\_ibegin, zoom\_jbegin, zoom\_ni, zoom\_nj  &
1014    domain\_\-definition, domain\_group                                 &
1015    none                    \\
1016    \hline
1017  \end{tabularx}
1018  \caption{XIOS: domain tags ("\texttt{domain\_*)}"}
1019\end{table}
1020
1021\begin{table}
1022  \begin{tabularx}{\textwidth}{|l|X|X|X|X|}
1023    \hline
1024    tag name                                                                                     &
1025    description                                                                                  &
1026    accepted attribute                                                                           &
1027    child of                                                                                     &
1028    parent of                       \\
1029    \hline
1030    \hline
1031    grid\_definition                                                                               &
1032    define all the grid (association of a domain and/or an axis) potentially used by the variables &
1033    src                                                                                            &
1034    context                                                                                        &
1035    grid\_group, grid   \\
1036    \hline
1037    grid\_group                                                                                    &
1038    encapsulates a group of grids                                                                  &
1039    id, domain\_ref,axis\_ref                                                                      &
1040    grid\_definition, grid\_group                                                                  &
1041    grid\_group, grid   \\
1042    \hline
1043    grid                                                                                           &
1044    define a grid                                                                                  &
1045    id, domain\_ref,axis\_ref                                                                      &
1046    grid\_definition, grid\_group                                                                  &
1047    none                \\
1048    \hline
1049  \end{tabularx}
1050  \caption{XIOS: grid tags ("\texttt{grid\_*}")}
1051\end{table}
1052
1053\subsubsection{Attributes list per family}
1054
1055\begin{table}
1056  \begin{tabularx}{\textwidth}{|l|X|l|l|}
1057    \hline
1058    attribute name                           &
1059    description                              &
1060    example                                  &
1061    accepted by            \\
1062    \hline
1063    \hline
1064    axis\_ref                                &
1065    refers to the id of a vertical axis      &
1066    axis\_ref="deptht"                       &
1067    field, grid families   \\
1068    \hline
1069    domain\_ref                              &
1070    refers to the id of a domain             &
1071    domain\_ref="grid\_T"                    &
1072    field or grid families \\
1073    \hline
1074    field\_ref                               &
1075    id of the field we want to add in a file &
1076    field\_ref="toce"                        &
1077    field                  \\
1078    \hline
1079    grid\_ref                                &
1080    refers to the id of a grid               &
1081    grid\_ref="grid\_T\_2D"                  &
1082    field family           \\
1083    \hline
1084    group\_ref                               &
1085    refer to a group of variables            &
1086    group\_ref="mooring"                     &
1087    field\_group           \\
1088    \hline
1089  \end{tabularx}
1090  \caption{XIOS: reference attributes ("\texttt{*\_ref}")}
1091\end{table}
1092
1093\begin{table}
1094  \begin{tabularx}{\textwidth}{|l|X|l|l|}
1095    \hline
1096    attribute name                                     &
1097    description                                        &
1098    example                                            &
1099    accepted by   \\
1100    \hline
1101    \hline
1102    zoom\_ibegin                                       &
1103    starting point along x direction of the zoom.
1104    Automatically defined for TAO/RAMA/PIRATA moorings &
1105    zoom\_ibegin="1"                                   &
1106    domain family \\
1107    \hline
1108    zoom\_jbegin                                       &
1109    starting point along y direction of the zoom.
1110    Automatically defined for TAO/RAMA/PIRATA moorings &
1111    zoom\_jbegin="1"                                   &
1112    domain family \\
1113    \hline
1114    zoom\_ni                                           &
1115    zoom extent along x direction                      &
1116    zoom\_ni="1"                                       &
1117    domain family \\
1118    \hline
1119    zoom\_nj                                           &
1120    zoom extent along y direction                      &
1121    zoom\_nj="1"                                       &
1122    domain family \\
1123    \hline
1124  \end{tabularx}
1125  \caption{XIOS: domain attributes ("\texttt{zoom\_*}")}
1126\end{table}
1127
1128\begin{table}
1129  \begin{tabularx}{\textwidth}{|l|X|l|l|}
1130    \hline
1131    attribute name                                                                                       &
1132    description                                                                                          &
1133    example                                                                                              &
1134    accepted by                            \\
1135    \hline
1136    \hline
1137    min\_digits                                                                                          &
1138    specify the minimum of digits used in the core number in the name of the NetCDF file                 &
1139    min\_digits="4"                                                                                      &
1140    file family                            \\
1141    \hline
1142    name\_suffix                                                                                         &
1143    suffix to be inserted after the name and before the cpu number and the ''.nc'' termination of a file &
1144    name\_suffix="\_myzoom"                                                                              &
1145    file family                            \\
1146    \hline
1147    output\_level                                                                                        &
1148    output priority of variables in a file: 0 (high) to 10 (low).
1149    All variables listed in the file with a level smaller or equal to output\_level will be output.
1150    Other variables won't be output even if they are listed in the file.                                 &
1151    output\_level="10"                                                                                   &
1152    file family                            \\
1153    \hline
1154    split\_freq                                                                                          &
1155    frequency at which to temporally split output files.
1156    Units can be ts (timestep), y, mo, d, h, mi, s.
1157    Useful for long runs to prevent over-sized output files.                                             &
1158    split\_freq="1mo"                                                                                    &
1159    file family                            \\
1160    \hline
1161    split\_freq\-\_format                                                                                &
1162    date format used in the name of temporally split output files.
1163    Can be specified using the following syntaxes: \%y, \%mo, \%d, \%h \%mi and \%s                      &
1164    split\_freq\_format= "\%y\%mo\%d"                                                                    &
1165    file family                            \\
1166    \hline
1167    sync\_freq                                                                                           &
1168    NetCDF file synchronization frequency (update of the time\_counter).
1169    Units can be ts (timestep), y, mo, d, h, mi, s.                                                      &
1170    sync\_freq="10d"                                                                                     &
1171    file family                            \\
1172    \hline
1173    type (1)                                                                                             &
1174    specify if the output files are to be split spatially (multiple\_file) or not (one\_file)            &
1175    type="multiple\_file"                                                                                &
1176    file familly                           \\
1177    \hline
1178  \end{tabularx}
1179  \caption{XIOS: file attributes}
1180\end{table}
1181
1182\begin{table}
1183  \begin{tabularx}{\textwidth}{|l|X|l|l|}
1184    \hline
1185    attribute name                                                                                       &
1186    description                                                                                          &
1187    example                                                                                              &
1188    accepted by                            \\
1189    \hline
1190    \hline
1191    default\_value                                                                                       &
1192    missing\_value definition                                                                            &
1193    default\_value="1.e20"                                                                               &
1194    field family                           \\
1195    \hline
1196    level                                                                                                &
1197    output priority of a field: 0 (high) to 10 (low)                                                     &
1198    level="1"                                                                                            &
1199    field family                           \\
1200    \hline
1201    operation                                                                                            &
1202    type of temporal operation: average, accumulate, instantaneous, min, max and once                    &
1203    operation="average"                                                                                  &
1204    field family                           \\
1205    \hline
1206    output\_freq                                                                                         &
1207    operation frequency. units can be ts (timestep), y, mo, d, h, mi, s.                                 &
1208    output\_freq="1d12h"                                                                                 &
1209    field family                           \\
1210    \hline
1211    prec                                                                                                 &
1212    output precision: real 4 or real 8                                                                   &
1213    prec="4"                                                                                             &
1214    field family                           \\
1215    \hline
1216    long\_name                                                                                           &
1217    define the long\_name attribute in the NetCDF file                                                   &
1218    long\_name="Vertical T levels"                                                                       &
1219    field                                  \\
1220    \hline
1221    standard\_name                                                                                       &
1222    define the standard\_name attribute in the NetCDF file                                               &
1223    standard\_name= "Eastward\_Sea\_Ice\_Transport"                                                      &
1224    field                                  \\
1225    \hline
1226  \end{tabularx}
1227  \caption{XIOS: field attributes}
1228\end{table}
1229
1230\begin{table}
1231  \begin{tabularx}{\textwidth}{|l|X|X|X|}
1232    \hline
1233    attribute name                                                                                       &
1234    description                                                                                          &
1235    example                                                                                              &
1236    accepted by                            \\
1237    \hline
1238    \hline
1239    enabled                                                                                              &
1240    switch on/off the output of a field or a file                                                        &
1241    enabled=".true."                                                                                     &
1242    field, file families                   \\
1243    \hline
1244    description                                                                                          &
1245    just for information, not used                                                                       &
1246    description="ocean T grid variables"                                                                 &
1247    all tags                               \\
1248    \hline
1249    id                                                                                                   &
1250    allow to identify a tag                                                                              &
1251    id="nemo"                                                                                            &
1252    accepted by all tags except simulation \\
1253    \hline
1254    name                                                                                                 &
1255    name of a variable or a file. If the name of a file is undefined, its id is used as a name           &
1256    name="tos"                                                                                           &
1257    field or file families                 \\
1258    \hline
1259    positive                                                                                             &
1260    convention used for the orientation of vertival axis (positive downward in \NEMO).                   &
1261    positive="down"                                                                                      &
1262    axis family                            \\
1263    \hline
1264    src                                                                                                  &
1265    allow to include a file                                                                              &
1266    src="./field\_def.xml"                                                                               &
1267    accepted by all tags except simulation \\
1268    \hline
1269    time\_origin                                                                                         &
1270    specify the origin of the time counter                                                               &
1271    time\_origin="1900-01-01 00:00:00"                                                                   &
1272    context                                \\
1273    \hline
1274    type (2)                                                                                             &
1275    define the type of a variable tag                                                                    &
1276    type="boolean"                                                                                       &
1277    variable                               \\
1278    \hline
1279    unit                                                                                                 &
1280    unit of a variable or the vertical axis                                                              &
1281    unit="m"                                                                                             &
1282    field and axis families                \\
1283    \hline
1284  \end{tabularx}
1285  \caption{XIOS: miscellaneous attributes}
1286\end{table}
1287
1288\subsection{CF metadata standard compliance}
1289
1290Output from the XIOS IO server is compliant with
1291\href{http://cfconventions.org/Data/cf-conventions/cf-conventions-1.5/build/cf-conventions.html}{version 1.5} of
1292the CF metadata standard.
1293Therefore while a user may wish to add their own metadata to the output files (as demonstrated in example 4 of
1294section \autoref{subsec:DIA_IOM_xmlref}) the metadata should, for the most part, comply with the CF-1.5 standard.
1295
1296Some metadata that may significantly increase the file size (horizontal cell areas and vertices) are controlled by
1297the namelist parameter \np{ln_cfmeta}{ln\_cfmeta} in the \nam{run}{run} namelist.
1298This must be set to true if these metadata are to be included in the output files.
1299
1300\section[NetCDF4 support (\texttt{\textbf{key\_netcdf4}})]{NetCDF4 support (\protect\key{netcdf4})}
1301\label{sec:DIA_nc4}
1302
1303Since version 3.3, support for NetCDF4 chunking and (loss-less) compression has been included.
1304These options build on the standard NetCDF output and allow the user control over the size of the chunks via
1305namelist settings.
1306Chunking and compression can lead to significant reductions in file sizes for a small runtime overhead.
1307For a fuller discussion on chunking and other performance issues the reader is referred to
1308the NetCDF4 documentation found \href{https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_perf_chunking.html}{here}.
1309
1310The new features are only available when the code has been linked with a NetCDF4 library
1311(version 4.1 onwards, recommended) which has been built with HDF5 support (version 1.8.4 onwards, recommended).
1312Datasets created with chunking and compression are not backwards compatible with NetCDF3 "classic" format but
1313most analysis codes can be relinked simply with the new libraries and will then read both NetCDF3 and NetCDF4 files.
1314\NEMO\ executables linked with NetCDF4 libraries can be made to produce NetCDF3 files by
1315setting the \np{ln_nc4zip}{ln\_nc4zip} logical to false in the \nam{nc4}{nc4} namelist:
1316
1317%------------------------------------------namnc4----------------------------------------------------
1318
1319\begin{listing}
1320  \nlst{namnc4}
1321  \caption{\forcode{&namnc4}}
1322  \label{lst:namnc4}
1323\end{listing}
1324%-------------------------------------------------------------------------------------------------------------
1325
1326If \key{netcdf4} has not been defined, these namelist parameters are not read.
1327In this case, \np{ln_nc4zip}{ln\_nc4zip} is set false and dummy routines for a few NetCDF4-specific functions are defined.
1328These functions will not be used but need to be included so that compilation is possible with NetCDF3 libraries.
1329
1330When using NetCDF4 libraries, \key{netcdf4} should be defined even if the intention is to
1331create only NetCDF3-compatible files.
1332This is necessary to avoid duplication between the dummy routines and the actual routines present in the library.
1333Most compilers will fail at compile time when faced with such duplication.
1334Thus when linking with NetCDF4 libraries the user must define \key{netcdf4} and
1335control the type of NetCDF file produced via the namelist parameter.
1336
1337Chunking and compression is applied only to 4D fields and
1338there is no advantage in chunking across more than one time dimension since
1339previously written chunks would have to be read back and decompressed before being added to.
1340Therefore, user control over chunk sizes is provided only for the three space dimensions.
1341The user sets an approximate number of chunks along each spatial axis.
1342The actual size of the chunks will depend on global domain size for mono-processors or, more likely,
1343the local processor domain size for distributed processing.
1344The derived values are subject to practical minimum values (to avoid wastefully small chunk sizes) and
1345cannot be greater than the domain size in any dimension.
1346The algorithm used is:
1347
1348\begin{forlines}
1349ichunksz(1) = MIN(idomain_size, MAX((idomain_size-1) / nn_nchunks_i + 1 ,16 ))
1350ichunksz(2) = MIN(jdomain_size, MAX((jdomain_size-1) / nn_nchunks_j + 1 ,16 ))
1351ichunksz(3) = MIN(kdomain_size, MAX((kdomain_size-1) / nn_nchunks_k + 1 , 1 ))
1352ichunksz(4) = 1
1353\end{forlines}
1354
1355\noindent As an example, setting:
1356
1357\begin{forlines}
1358nn_nchunks_i=4, nn_nchunks_j=4 and nn_nchunks_k=31
1359\end{forlines}
1360
1361\noindent for a standard ORCA2\_LIM configuration gives chunksizes of {\small\texttt 46x38x1} respectively in
1362the mono-processor case (\ie\ global domain of {\small\texttt 182x149x31}).
1363An illustration of the potential space savings that NetCDF4 chunking and compression provides is given in
1364table \autoref{tab:DIA_NC4} which compares the results of two short runs of the ORCA2\_LIM reference configuration with
1365a 4x2 mpi partitioning.
1366Note the variation in the compression ratio achieved which reflects chiefly the dry to wet volume ratio of
1367each processing region.
1368
1369%------------------------------------------TABLE----------------------------------------------------
1370\begin{table}
1371  \centering
1372  \begin{tabular}{lrrr}
1373    Filename                    & NetCDF3 & NetCDF4  & Reduction \\
1374                                & filesize   & filesize & \%        \\
1375                                & (KB)    & (KB)     &           \\
1376    ORCA2\_restart\_0000.nc     & 16420   & 8860     & 47\%      \\
1377    ORCA2\_restart\_0001.nc     & 16064   & 11456    & 29\%      \\
1378    ORCA2\_restart\_0002.nc     & 16064      & 9744     & 40\%      \\
1379    ORCA2\_restart\_0003.nc     & 16420      & 9404     & 43\%      \\
1380    ORCA2\_restart\_0004.nc     & 16200   & 5844     & 64\%      \\
1381    ORCA2\_restart\_0005.nc     & 15848   & 8172     & 49\%      \\
1382    ORCA2\_restart\_0006.nc     & 15848   & 8012     & 50\%      \\
1383    ORCA2\_restart\_0007.nc     & 16200   & 5148     & 69\%      \\
1384    ORCA2\_2d\_grid\_T\_0000.nc & 2200       & 1504     & 32\%      \\
1385    ORCA2\_2d\_grid\_T\_0001.nc & 2200       & 1748     & 21\%      \\
1386    ORCA2\_2d\_grid\_T\_0002.nc & 2200       & 1592     & 28\%      \\
1387    ORCA2\_2d\_grid\_T\_0003.nc & 2200       & 1540     & 30\%      \\
1388    ORCA2\_2d\_grid\_T\_0004.nc & 2200       & 1204     & 46\%      \\
1389    ORCA2\_2d\_grid\_T\_0005.nc & 2200       & 1444     & 35\%      \\
1390    ORCA2\_2d\_grid\_T\_0006.nc & 2200       & 1428     & 36\%      \\
1391    ORCA2\_2d\_grid\_T\_0007.nc & 2200    & 1148     & 48\%      \\
1392    ...                         & ...     & ...      & ...       \\
1393    ORCA2\_2d\_grid\_W\_0000.nc & 4416    & 2240     & 50\%      \\
1394    ORCA2\_2d\_grid\_W\_0001.nc & 4416    & 2924     & 34\%      \\
1395    ORCA2\_2d\_grid\_W\_0002.nc & 4416    & 2512     & 44\%      \\
1396    ORCA2\_2d\_grid\_W\_0003.nc & 4416    & 2368     & 47\%      \\
1397    ORCA2\_2d\_grid\_W\_0004.nc & 4416    & 1432     & 68\%      \\
1398    ORCA2\_2d\_grid\_W\_0005.nc & 4416    & 1972     & 56\%      \\
1399    ORCA2\_2d\_grid\_W\_0006.nc & 4416    & 2028     & 55\%      \\
1400    ORCA2\_2d\_grid\_W\_0007.nc & 4416    & 1368     & 70\%      \\
1401  \end{tabular}
1402  \caption{Filesize comparison between NetCDF3 and NetCDF4 with chunking and compression}
1403  \label{tab:DIA_NC4}
1404\end{table}
1405%----------------------------------------------------------------------------------------------------
1406
1407When \key{iomput} is activated with \key{netcdf4} chunking and compression parameters for fields produced via
1408\rou{iom\_put} calls are set via an equivalent and identically named namelist to \nam{nc4}{nc4} in
1409\textit{xmlio\_server.def}.
1410Typically this namelist serves the mean files whilst the \nam{nc4}{nc4} in the main namelist file continues to
1411serve the restart files.
1412This duplication is unfortunate but appropriate since, if using io\_servers, the domain sizes of
1413the individual files produced by the io\_server processes may be different to those produced by
1414the invidual processing regions and different chunking choices may be desired.
1415
1416\section[Tracer/Dynamics trends (\forcode{&namtrd})]{Tracer/Dynamics trends (\protect\nam{trd}{trd})}
1417\label{sec:DIA_trd}
1418
1419%------------------------------------------namtrd----------------------------------------------------
1420
1421\begin{listing}
1422  \nlst{namtrd}
1423  \caption{\forcode{&namtrd}}
1424  \label{lst:namtrd}
1425\end{listing}
1426%-------------------------------------------------------------------------------------------------------------
1427
1428Each trend of the dynamics and/or temperature and salinity time evolution equations can be send to
1429\mdl{trddyn} and/or \mdl{trdtra} modules (see TRD directory) just after their computation
1430(\ie\ at the end of each \textit{dyn....F90} and/or \textit{tra....F90} routines).
1431This capability is controlled by options offered in \nam{trd}{trd} namelist.
1432Note that the output are done with XIOS, and therefore the \key{iomput} is required.
1433
1434What is done depends on the \nam{trd}{trd} logical set to \forcode{.true.}:
1435
1436\begin{description}
1437\item [{\np{ln_glo_trd}{ln\_glo\_trd}}]:
1438  at each \np{nn_trd}{nn\_trd} time-step a check of the basin averaged properties of
1439  the momentum and tracer equations is performed.
1440  This also includes a check of $T^2$, $S^2$, $\tfrac{1}{2} (u^2+v2)$,
1441  and potential energy time evolution equations properties;
1442\item [{\np{ln_dyn_trd}{ln\_dyn\_trd}}]:
1443  each 3D trend of the evolution of the two momentum components is output;
1444\item [{\np{ln_dyn_mxl}{ln\_dyn\_mxl}}]:
1445  each 3D trend of the evolution of the two momentum components averaged over the mixed layer is output;
1446\item [{\np{ln_vor_trd}{ln\_vor\_trd}}]:
1447  a vertical summation of the moment tendencies is performed,
1448  then the curl is computed to obtain the barotropic vorticity tendencies which are output;
1449\item [{\np{ln_KE_trd}{ln\_KE\_trd}}] :
1450  each 3D trend of the Kinetic Energy equation is output;
1451\item [{\np{ln_tra_trd}{ln\_tra\_trd}}]:
1452  each 3D trend of the evolution of temperature and salinity is output;
1453\item [{\np{ln_tra_mxl}{ln\_tra\_mxl}}]:
1454  each 2D trend of the evolution of temperature and salinity averaged over the mixed layer is output;
1455\end{description}
1456
1457Note that the mixed layer tendency diagnostic can also be used on biogeochemical models via
1458the \key{trdtrc} and \key{trdmxl\_trc} CPP keys.
1459
1460\textbf{Note that} in the current version (v3.6), many changes has been introduced but not fully tested.
1461In particular, options associated with \np{ln_dyn_mxl}{ln\_dyn\_mxl}, \np{ln_vor_trd}{ln\_vor\_trd}, and \np{ln_tra_mxl}{ln\_tra\_mxl} are not working,
1462and none of the options have been tested with variable volume (\ie\ \np[=.true.]{ln_linssh}{ln\_linssh}).
1463
1464\section[FLO: On-Line Floats trajectories (\texttt{\textbf{key\_floats}})]{FLO: On-Line Floats trajectories (\protect\key{floats})}
1465\label{sec:DIA_FLO}
1466%--------------------------------------------namflo-------------------------------------------------------
1467
1468\begin{listing}
1469  \nlst{namflo}
1470  \caption{\forcode{&namflo}}
1471  \label{lst:namflo}
1472\end{listing}
1473%--------------------------------------------------------------------------------------------------------------
1474
1475The on-line computation of floats advected either by the three dimensional velocity field or constraint to
1476remain at a given depth ($w = 0$ in the computation) have been introduced in the system during the CLIPPER project.
1477Options are defined by \nam{flo}{flo} namelist variables.
1478The algorithm used is based either on the work of \cite{blanke.raynaud_JPO97} (default option),
1479or on a $4^th$ Runge-Hutta algorithm (\np[=.true.]{ln_flork4}{ln\_flork4}).
1480Note that the \cite{blanke.raynaud_JPO97} algorithm have the advantage of providing trajectories which
1481are consistent with the numeric of the code, so that the trajectories never intercept the bathymetry.
1482
1483\subsubsection{Input data: initial coordinates}
1484
1485Initial coordinates can be given with Ariane Tools convention
1486(IJK coordinates, (\np[=.true.]{ln_ariane}{ln\_ariane}) ) or with longitude and latitude.
1487
1488In case of Ariane convention, input filename is \textit{init\_float\_ariane}.
1489Its format is: \\
1490{ \texttt{I J K nisobfl itrash}}
1491
1492\noindent with:
1493
1494 - I,J,K  : indexes of initial position
1495
1496 - nisobfl: 0 for an isobar float, 1 for a float following the w velocity
1497
1498 - itrash : set to zero; it is a dummy variable to respect Ariane Tools convention
1499
1500\noindent Example: \\
1501\noindent
1502{
1503  \texttt{
1504    100.00000  90.00000  -1.50000 1.00000   0.00000   \\
1505    102.00000  90.00000  -1.50000 1.00000   0.00000   \\
1506    104.00000  90.00000  -1.50000 1.00000   0.00000   \\
1507    106.00000  90.00000  -1.50000 1.00000   0.00000   \\
1508    108.00000  90.00000  -1.50000 1.00000   0.00000}
1509} \\
1510
1511In the other case (longitude and latitude), input filename is init\_float.
1512Its format is: \\
1513{ \texttt{Long Lat depth nisobfl ngrpfl itrash}}
1514
1515\noindent with:
1516
1517 - Long, Lat, depth  : Longitude, latitude, depth
1518
1519 - nisobfl: 0 for an isobar float, 1 for a float following the w velocity
1520
1521 - ngrpfl : number to identify searcher group
1522
1523 - itrash :set to 1; it is a dummy variable.
1524
1525\noindent Example: \\
1526\noindent
1527{
1528  \texttt{
1529    20.0 0.0 0.0 0 1 1    \\
1530    -21.0 0.0 0.0 0 1 1    \\
1531    -22.0 0.0 0.0 0 1 1    \\
1532    -23.0 0.0 0.0 0 1 1    \\
1533    -24.0 0.0 0.0 0 1 1 }
1534} \\
1535
1536\np{jpnfl}{jpnfl} is the total number of floats during the run.
1537When initial positions are read in a restart file (\np[=.true.]{ln_rstflo}{ln\_rstflo} ),
1538\np{jpnflnewflo}{jpnflnewflo} can be added in the initialization file.
1539
1540\subsubsection{Output data}
1541
1542\np{nn_writefl}{nn\_writefl} is the frequency of writing in float output file and \np{nn_stockfl}{nn\_stockfl} is the frequency of
1543creation of the float restart file.
1544
1545Output data can be written in ascii files (\np[=.true.]{ln_flo_ascii}{ln\_flo\_ascii}).
1546In that case, output filename is trajec\_float.
1547
1548Another possiblity of writing format is Netcdf (\np[=.false.]{ln_flo_ascii}{ln\_flo\_ascii}) with
1549\key{iomput} and outputs selected in iodef.xml.
1550Here it is an example of specification to put in files description section:
1551
1552\begin{xmllines}
1553<group id="1d_grid_T" name="auto" description="ocean T grid variables" >   }
1554   <file id="floats"  description="floats variables"> }
1555      <field ref="traj_lon"   name="floats_longitude"   freq_op="86400" />}
1556      <field ref="traj_lat"   name="floats_latitude"    freq_op="86400" />}
1557      <field ref="traj_dep"   name="floats_depth"       freq_op="86400" />}
1558      <field ref="traj_temp"  name="floats_temperature" freq_op="86400" />}
1559      <field ref="traj_salt"  name="floats_salinity"    freq_op="86400" />}
1560      <field ref="traj_dens"  name="floats_density"     freq_op="86400" />}
1561      <field ref="traj_group" name="floats_group"       freq_op="86400" />}
1562   </file>}
1563</group>}
1564\end{xmllines}
1565
1566\section[Harmonic analysis of tidal constituents (\texttt{\textbf{key\_diaharm}})]{Harmonic analysis of tidal constituents (\protect\key{diaharm})}
1567\label{sec:DIA_diag_harm}
1568
1569%------------------------------------------nam_diaharm----------------------------------------------------
1570%
1571\begin{listing}
1572  \nlst{nam_diaharm}
1573  \caption{\forcode{&nam_diaharm}}
1574  \label{lst:nam_diaharm}
1575\end{listing}
1576%----------------------------------------------------------------------------------------------------------
1577
1578A module is available to compute the amplitude and phase of tidal waves.
1579This on-line Harmonic analysis is actived with \key{diaharm}.
1580
1581Some parameters are available in namelist \nam{_diaharm}{\_diaharm}:
1582
1583 - \np{nit000_han}{nit000\_han} is the first time step used for harmonic analysis
1584
1585 - \np{nitend_han}{nitend\_han} is the  last time step used for harmonic analysis
1586
1587 - \np{nstep_han}{nstep\_han}  is the  time step frequency for harmonic analysis
1588
1589% - \np{nb_ana}{nb\_ana}     is the number of harmonics to analyse
1590
1591 - \np{tname}{tname}       is an array with names of tidal constituents to analyse
1592
1593 \np{nit000_han}{nit000\_han} and \np{nitend_han}{nitend\_han} must be between \np{nit000}{nit000} and \np{nitend}{nitend} of the simulation.
1594 The restart capability is not implemented.
1595
1596 The Harmonic analysis solve the following equation:
1597
1598 \[
1599   h_{i} - A_{0} + \sum^{nb\_ana}_{j=1}[A_{j}cos(\nu_{j}t_{j}-\phi_{j})] = e_{i}
1600 \]
1601
1602With $A_{j}$, $\nu_{j}$, $\phi_{j}$, the amplitude, frequency and phase for each wave and $e_{i}$ the error.
1603$h_{i}$ is the sea level for the time $t_{i}$ and $A_{0}$ is the mean sea level. \\
1604We can rewrite this equation:
1605
1606\[
1607  h_{i} - A_{0} + \sum^{nb\_ana}_{j=1}[C_{j}cos(\nu_{j}t_{j})+S_{j}sin(\nu_{j}t_{j})] = e_{i}
1608\]
1609
1610with $A_{j}=\sqrt{C^{2}_{j}+S^{2}_{j}}$ and $\phi_{j}=arctan(S_{j}/C_{j})$.
1611
1612We obtain in output $C_{j}$ and $S_{j}$ for each tidal wave.
1613
1614\section[Transports across sections (\texttt{\textbf{key\_diadct}})]{Transports across sections (\protect\key{diadct})}
1615\label{sec:DIA_diag_dct}
1616
1617%------------------------------------------nam_diadct----------------------------------------------------
1618
1619\begin{listing}
1620  \nlst{nam_diadct}
1621  \caption{\forcode{&nam_diadct}}
1622  \label{lst:nam_diadct}
1623\end{listing}
1624%-------------------------------------------------------------------------------------------------------------
1625
1626A module is available to compute the transport of volume, heat and salt through sections.
1627This diagnostic is actived with \key{diadct}.
1628
1629Each section is defined by the coordinates of its 2 extremities.
1630The pathways between them are contructed using tools which can be found in \texttt{tools/SECTIONS\_DIADCT}
1631and are written in a binary file \texttt{section\_ijglobal.diadct} which is later read in by
1632\NEMO\ to compute on-line transports.
1633
1634The on-line transports module creates three output ascii files:
1635
1636- \texttt{volume\_transport} for volume transports (unit: $10^{6} m^{3} s^{-1}$)
1637
1638- \texttt{heat\_transport}   for   heat transports (unit: $10^{15} W$)
1639
1640- \texttt{salt\_transport}   for   salt transports (unit: $10^{9}Kg s^{-1}$) \\
1641
1642Namelist variables in \nam{_diadct}{\_diadct} control how frequently the flows are summed and the time scales over which
1643they are averaged, as well as the level of output for debugging:
1644\np{nn_dct}{nn\_dct}   : frequency of instantaneous transports computing
1645\np{nn_dctwri}{nn\_dctwri}: frequency of writing ( mean of instantaneous transports )
1646\np{nn_debug}{nn\_debug} : debugging of the section
1647
1648\subsubsection{Creating a binary file containing the pathway of each section}
1649
1650In \texttt{tools/SECTIONS\_DIADCT/run},
1651the file \textit{ {list\_sections.ascii\_global}} contains a list of all the sections that are to be computed
1652(this list of sections is based on MERSEA project metrics).
1653
1654Another file is available for the GYRE configuration (\texttt{ {list\_sections.ascii\_GYRE}}).
1655
1656Each section is defined by: \\
1657\noindent { \texttt{long1 lat1 long2 lat2 nclass (ok/no)strpond (no)ice section\_name}} \\
1658with:
1659
1660 - \texttt{long1 lat1}, coordinates of the  first extremity of the section;
1661
1662 - \texttt{long2 lat2}, coordinates of the second extremity of the section;
1663
1664 - \texttt{nclass}    the number of bounds of your classes (\eg\ bounds for 2 classes);
1665
1666 - \texttt{okstrpond} to compute    heat and       salt transports, \texttt{nostrpond} if no;
1667
1668 - \texttt{ice}       to compute surface and volume ice transports, \texttt{noice}     if no. \\
1669
1670 \noindent The results of the computing of transports, and the directions of positive and
1671 negative flow do not depend on the order of the 2 extremities in this file. \\
1672
1673\noindent If nclass $\neq$ 0, the next lines contain the class type and the nclass bounds: \\
1674{
1675  \texttt{
1676    long1 lat1 long2 lat2 nclass (ok/no)strpond (no)ice section\_name \\
1677    classtype                                                         \\
1678    zbound1                                                           \\
1679    zbound2                                                           \\
1680    .                                                                 \\
1681    .                                                                 \\
1682    nclass-1                                                          \\
1683    nclass}
1684}
1685
1686\noindent where \texttt{classtype} can be:
1687
1688 - \texttt{zsal}  for          salinity classes
1689
1690 - \texttt{ztem}  for       temperature classes
1691
1692 - \texttt{zlay}  for             depth classes
1693
1694 - \texttt{zsigi} for    insitu density classes
1695
1696 - \texttt{zsigp} for potential density classes \\
1697
1698 The script \texttt{job.ksh} computes the pathway for each section and creates a binary file
1699 \texttt{section\_ijglobal.diadct} which is read by \NEMO. \\
1700
1701 It is possible to use this tools for new configuations: \texttt{job.ksh} has to be updated with
1702 the coordinates file name and path. \\
1703
1704 Examples of two sections, the ACC\_Drake\_Passage with no classes,
1705 and the ATL\_Cuba\_Florida with 4 temperature clases (5 class bounds), are shown: \\
1706 \noindent
1707 {
1708   \texttt{
1709     -68.    -54.5   -60.    -64.7  00 okstrpond noice ACC\_Drake\_Passage \\
1710     -80.5    22.5   -80.5    25.5  05 nostrpond noice ATL\_Cuba\_Florida  \\
1711     ztem                                                                  \\
1712     -2.0                                                                  \\
1713     4.5                                                                  \\
1714     7.0                                                                  \\
1715     12.0                                                                  \\
1716     40.0}
1717 }
1718
1719\subsubsection{To read the output files}
1720
1721The output format is: \\
1722{
1723  \texttt{
1724    date, time-step number, section number,                \\
1725    section name, section slope coefficient, class number, \\
1726    class name, class bound 1 , classe bound2,             \\
1727    transport\_direction1, transport\_direction2,          \\
1728    transport\_total}
1729}                                     \\
1730
1731For sections with classes, the first \texttt{nclass-1} lines correspond to the transport for each class and
1732the last line corresponds to the total transport summed over all classes.
1733For sections with no classes, class number \texttt{1} corresponds to \texttt{total class} and
1734this class is called \texttt{N}, meaning \texttt{none}.
1735
1736- \texttt{transport\_direction1} is the positive part of the transport ($\geq$ 0).
1737
1738- \texttt{transport\_direction2} is the negative part of the transport ($\leq$ 0). \\
1739
1740\noindent The \texttt{section slope coefficient} gives information about the significance of transports signs and
1741direction: \\
1742
1743\begin{table}
1744  \begin{tabular}{|l|l|l|l|l|}
1745    \hline
1746    section slope coefficient      & section type & direction 1 & direction 2 & total transport    \\
1747    \hline
1748    0.                             & horizontal  & northward   & southward   & postive: northward    \\
1749    \hline
1750    1000.                          & vertical     & eastward    & westward    & postive: eastward     \\
1751    \hline
1752    \texttt{$\neq$ 0, $\neq$ 1000.} & diagonal     & eastward    & westward     & postive: eastward      \\
1753    \hline
1754  \end{tabular}
1755\end{table}
1756
1757\section{Diagnosing the steric effect in sea surface height}
1758\label{sec:DIA_steric}
1759
1760Changes in steric sea level are caused when changes in the density of the water column imply an expansion or
1761contraction of the column.
1762It is essentially produced through surface heating/cooling and to a lesser extent through non-linear effects of
1763the equation of state (cabbeling, thermobaricity...).
1764Non-Boussinesq models contain all ocean effects within the ocean acting on the sea level.
1765In particular, they include the steric effect.
1766In contrast, Boussinesq models, such as \NEMO, conserve volume, rather than mass,
1767and so do not properly represent expansion or contraction.
1768The steric effect is therefore not explicitely represented.
1769This approximation does not represent a serious error with respect to the flow field calculated by the model
1770\citep{greatbatch_JGR94}, but extra attention is required when investigating sea level,
1771as steric changes are an important contribution to local changes in sea level on seasonal and climatic time scales.
1772This is especially true for investigation into sea level rise due to global warming.
1773
1774Fortunately, the steric contribution to the sea level consists of a spatially uniform component that
1775can be diagnosed by considering the mass budget of the world ocean \citep{greatbatch_JGR94}.
1776In order to better understand how global mean sea level evolves and thus how the steric sea level can be diagnosed,
1777we compare, in the following, the non-Boussinesq and Boussinesq cases.
1778
1779Let denote
1780$\mathcal{M}$ the total mass    of liquid seawater ($\mathcal{M} = \int_D \rho dv$),
1781$\mathcal{V}$ the total volume  of        seawater      ($\mathcal{V} = \int_D dv$),
1782$\mathcal{A}$ the total surface of       the ocean      ($\mathcal{A} = \int_S ds$),
1783$\bar{\rho}$ the global mean  seawater (\textit{in situ}) density
1784($\bar{\rho} = 1/\mathcal{V} \int_D \rho \,dv$), and
1785$\bar{\eta}$ the global mean sea level
1786($\bar{\eta} = 1/\mathcal{A} \int_S \eta \,ds$).
1787
1788A non-Boussinesq fluid conserves mass. It satisfies the following relations:
1789
1790\begin{equation}
1791  \begin{split}
1792    \mathcal{M} &\mathcal{V}  \;\bar{\rho} \\
1793    \mathcal{V} &\mathcal{A}  \;\bar{\eta}
1794  \end{split}
1795  \label{eq:DIA_MV_nBq}
1796\end{equation}
1797
1798Temporal changes in total mass is obtained from the density conservation equation:
1799
1800\begin{equation}
1801  \frac{1}{e_3} \partial_t ( e_3\,\rho) + \nabla( \rho \, \textbf{U} )
1802  = \left. \frac{\textit{emp}}{e_3}\right|_\textit{surface}
1803  \label{eq:DIA_Co_nBq}
1804\end{equation}
1805
1806where $\rho$ is the \textit{in situ} density, and \textit{emp} the surface mass exchanges with the other media of
1807the Earth system (atmosphere, sea-ice, land).
1808Its global averaged leads to the total mass change
1809
1810\begin{equation}
1811  \partial_t \mathcal{M} = \mathcal{A} \;\overline{\textit{emp}}
1812  \label{eq:DIA_Mass_nBq}
1813\end{equation}
1814
1815where $\overline{\textit{emp}} = \int_S \textit{emp}\,ds$ is the net mass flux through the ocean surface.
1816Bringing \autoref{eq:DIA_Mass_nBq} and the time derivative of \autoref{eq:DIA_MV_nBq} together leads to
1817the evolution equation of the mean sea level
1818
1819\begin{equation}
1820  \partial_t \bar{\eta} = \frac{\overline{\textit{emp}}}{ \bar{\rho}}
1821  - \frac{\mathcal{V}}{\mathcal{A}} \;\frac{\partial_t \bar{\rho} }{\bar{\rho}}
1822  \label{eq:DIA_ssh_nBq}
1823\end{equation}
1824
1825The first term in equation \autoref{eq:DIA_ssh_nBq} alters sea level by adding or subtracting mass from the ocean.
1826The second term arises from temporal changes in the global mean density; \ie\ from steric effects.
1827
1828In a Boussinesq fluid, $\rho$ is replaced by $\rho_o$ in all the equation except when $\rho$ appears multiplied by
1829the gravity (\ie\ in the hydrostatic balance of the primitive Equations).
1830In particular, the mass conservation equation, \autoref{eq:DIA_Co_nBq}, degenerates into the incompressibility equation:
1831
1832\[
1833  \frac{1}{e_3} \partial_t ( e_3 ) + \nabla( \textbf{U} ) = \left. \frac{\textit{emp}}{\rho_o \,e_3}\right|_ \textit{surface}
1834  % \label{eq:DIA_Co_Bq}
1835\]
1836
1837and the global average of this equation now gives the temporal change of the total volume,
1838
1839\[
1840  \partial_t \mathcal{V} = \mathcal{A} \;\frac{\overline{\textit{emp}}}{\rho_o}
1841  % \label{eq:DIA_V_Bq}
1842\]
1843
1844Only the volume is conserved, not mass, or, more precisely, the mass which is conserved is the Boussinesq mass,
1845$\mathcal{M}_o = \rho_o \mathcal{V}$.
1846The total volume (or equivalently the global mean sea level) is altered only by net volume fluxes across
1847the ocean surface, not by changes in mean mass of the ocean: the steric effect is missing in a Boussinesq fluid.
1848
1849Nevertheless, following \citep{greatbatch_JGR94}, the steric effect on the volume can be diagnosed by
1850considering the mass budget of the ocean.
1851The apparent changes in $\mathcal{M}$, mass of the ocean, which are not induced by surface mass flux
1852must be compensated by a spatially uniform change in the mean sea level due to expansion/contraction of the ocean
1853\citep{greatbatch_JGR94}.
1854In others words, the Boussinesq mass, $\mathcal{M}_o$, can be related to $\mathcal{M}$,
1855the total mass of the ocean seen by the Boussinesq model, via the steric contribution to the sea level,
1856$\eta_s$, a spatially uniform variable, as follows:
1857
1858\begin{equation}
1859  \mathcal{M}_o = \mathcal{M} + \rho_o \,\eta_s \,\mathcal{A}
1860  \label{eq:DIA_M_Bq}
1861\end{equation}
1862
1863Any change in $\mathcal{M}$ which cannot be explained by the net mass flux through the ocean surface
1864is converted into a mean change in sea level.
1865Introducing the total density anomaly, $\mathcal{D}= \int_D d_a \,dv$,
1866where $d_a = (\rho -\rho_o ) / \rho_o$ is the density anomaly used in \NEMO\ (cf. \autoref{subsec:TRA_eos})
1867in \autoref{eq:DIA_M_Bq} leads to a very simple form for the steric height:
1868
1869\begin{equation}
1870  \eta_s = - \frac{1}{\mathcal{A}} \mathcal{D}
1871  \label{eq:DIA_steric_Bq}
1872\end{equation}
1873
1874The above formulation of the steric height of a Boussinesq ocean requires four remarks.
1875First, one can be tempted to define $\rho_o$ as the initial value of $\mathcal{M}/\mathcal{V}$,
1876\ie\ set $\mathcal{D}_{t=0}=0$, so that the initial steric height is zero.
1877We do not recommend that.
1878Indeed, in this case $\rho_o$ depends on the initial state of the ocean.
1879Since $\rho_o$ has a direct effect on the dynamics of the ocean
1880(it appears in the pressure gradient term of the momentum equation)
1881it is definitively not a good idea when inter-comparing experiments.
1882We better recommend to fixe once for all $\rho_o$ to $1035\;Kg\,m^{-3}$.
1883This value is a sensible choice for the reference density used in a Boussinesq ocean climate model since,
1884with the exception of only a small percentage of the ocean, density in the World Ocean varies by no more than
18852$\%$ from this value (\cite{gill_bk82}, page 47).
1886
1887Second, we have assumed here that the total ocean surface, $\mathcal{A}$,
1888does not change when the sea level is changing as it is the case in all global ocean GCMs
1889(wetting and drying of grid point is not allowed).
1890
1891Third, the discretisation of \autoref{eq:DIA_steric_Bq} depends on the type of free surface which is considered.
1892In the non linear free surface case, \ie\ \np[=.true.]{ln_linssh}{ln\_linssh}, it is given by
1893
1894\[
1895  \eta_s = - \frac{ \sum_{i,\,j,\,k} d_a\; e_{1t} e_{2t} e_{3t} }{ \sum_{i,\,j,\,k}       e_{1t} e_{2t} e_{3t} }
1896  % \label{eq:DIA_discrete_steric_Bq_nfs}
1897\]
1898
1899whereas in the linear free surface,
1900the volume above the \textit{z=0} surface must be explicitly taken into account to
1901better approximate the total ocean mass and thus the steric sea level:
1902
1903\[
1904  \eta_s = - \frac{ \sum_{i,\,j,\,k} d_a\; e_{1t}e_{2t}e_{3t} + \sum_{i,\,j} d_a\; e_{1t}e_{2t} \eta }
1905                  { \sum_{i,\,j,\,k}       e_{1t}e_{2t}e_{3t} + \sum_{i,\,j}       e_{1t}e_{2t} \eta }
1906  % \label{eq:DIA_discrete_steric_Bq_fs}
1907\]
1908
1909The fourth and last remark concerns the effective sea level and the presence of sea-ice.
1910In the real ocean, sea ice (and snow above it)  depresses the liquid seawater through its mass loading.
1911This depression is a result of the mass of sea ice/snow system acting on the liquid ocean.
1912There is, however, no dynamical effect associated with these depressions in the liquid ocean sea level,
1913so that there are no associated ocean currents.
1914Hence, the dynamically relevant sea level is the effective sea level,
1915\ie\ the sea level as if sea ice (and snow) were converted to liquid seawater \citep{campin.marshall.ea_OM08}.
1916However, in the current version of \NEMO\ the sea-ice is levitating above the ocean without mass exchanges between
1917ice and ocean.
1918Therefore the model effective sea level is always given by $\eta + \eta_s$, whether or not there is sea ice present.
1919
1920In AR5 outputs, the thermosteric sea level is demanded.
1921It is steric sea level due to changes in ocean density arising just from changes in temperature.
1922It is given by:
1923
1924\[
1925  \eta_s = - \frac{1}{\mathcal{A}} \int_D d_a(T,S_o,p_o) \,dv
1926  % \label{eq:DIA_thermosteric_Bq}
1927\]
1928
1929where $S_o$ and $p_o$ are the initial salinity and pressure, respectively.
1930
1931Both steric and thermosteric sea level are computed in \mdl{diaar5}.
1932
1933\section{Other diagnostics}
1934\label{sec:DIA_diag_others}
1935
1936Aside from the standard model variables, other diagnostics can be computed on-line.
1937The available ready-to-add diagnostics modules can be found in directory DIA.
1938
1939\subsection[Depth of various quantities (\textit{diahth.F90})]{Depth of various quantities (\protect\mdl{diahth})}
1940
1941Among the available diagnostics the following ones are obtained when defining the \key{diahth} CPP key:
1942
1943- the mixed layer depth (based on a density criterion \citep{de-boyer-montegut.madec.ea_JGR04}) (\mdl{diahth})
1944
1945- the turbocline depth (based on a turbulent mixing coefficient criterion) (\mdl{diahth})
1946
1947- the depth of the 20\deg{C} isotherm (\mdl{diahth})
1948
1949- the depth of the thermocline (maximum of the vertical temperature gradient) (\mdl{diahth})
1950
1951\begin{figure}[!t]
1952  \centering
1953  \includegraphics[width=0.66\textwidth]{Fig_mask_subasins}
1954  \caption[Decomposition of the World Ocean to compute transports as well as
1955  the meridional stream-function]{
1956    Decomposition of the World Ocean (here ORCA2) into sub-basin used in to
1957    compute the heat and salt transports as well as the meridional stream-function:
1958    Atlantic basin (red), Pacific basin (green),
1959    Indian basin (blue), Indo-Pacific basin (blue+green).
1960    Note that semi-enclosed seas (Red, Med and Baltic seas) as well as
1961    Hudson Bay are removed from the sub-basins.
1962    Note also that the Arctic Ocean has been split into Atlantic and
1963    Pacific basins along the North fold line.
1964  }
1965  \label{fig:DIA_mask_subasins}
1966\end{figure}
1967
1968% -----------------------------------------------------------
1969%       CMIP specific diagnostics
1970% -----------------------------------------------------------
1971\subsection[CMIP specific diagnostics (\textit{diaar5.F90}, \textit{diaptr.F90})]{CMIP specific diagnostics (\protect\mdl{diaar5})}
1972
1973A series of diagnostics has been added in the \mdl{diaar5} and \mdl{diaptr}.
1974In \mdl{diaar5} they correspond to outputs that are required for AR5 simulations (CMIP5)
1975(see also \autoref{sec:DIA_steric} for one of them).
1976The module \mdl{diaar5} is active when one of the following outputs is required :
1977global total volume (voltot), global mean ssh (sshtot), global total mass (masstot), global mean temperature (temptot),
1978global mean ssh steric (sshsteric), global mean ssh thermosteric (sshthster), global mean salinity (saltot),
1979sea water pressure at sea floor (botpres), dynamic sea surface height (sshdyn).
1980
1981In \mdl{diaptr} when \np[=.true.]{ln_diaptr}{ln\_diaptr}
1982(see the \nam{ptr}{ptr} namelist below) can be computed on-line the poleward heat and salt transports,
1983their advective and diffusive component, and the meriodional stream function .
1984When \np[=.true.]{ln_subbas}{ln\_subbas}, transports and stream function are computed for the Atlantic, Indian,
1985Pacific and Indo-Pacific Oceans (defined north of 30\deg{S}) as well as for the World Ocean.
1986The sub-basin decomposition requires an input file (\ifile{subbasins}) which contains three 2D mask arrays,
1987the Indo-Pacific mask been deduced from the sum of the Indian and Pacific mask (\autoref{fig:DIA_mask_subasins}).
1988
1989%------------------------------------------namptr-----------------------------------------
1990
1991\begin{listing}
1992  \nlst{namptr}
1993  \caption{\forcode{&namptr}}
1994  \label{lst:namptr}
1995\end{listing}
1996%-----------------------------------------------------------------------------------------
1997
1998% -----------------------------------------------------------
1999%       25 hour mean and hourly Surface, Mid and Bed
2000% -----------------------------------------------------------
2001\subsection{25 hour mean output for tidal models}
2002
2003%------------------------------------------nam_dia25h-------------------------------------
2004
2005\begin{listing}
2006  \nlst{nam_dia25h}
2007  \caption{\forcode{&nam_dia25h}}
2008  \label{lst:nam_dia25h}
2009\end{listing}
2010%-----------------------------------------------------------------------------------------
2011
2012A module is available to compute a crudely detided M2 signal by obtaining a 25 hour mean.
2013The 25 hour mean is available for daily runs by summing up the 25 hourly instantananeous hourly values from
2014midnight at the start of the day to midight at the day end.
2015This diagnostic is actived with the logical $ln\_dia25h$.
2016
2017% -----------------------------------------------------------
2018%     Top Middle and Bed hourly output
2019% -----------------------------------------------------------
2020\subsection{Top middle and bed hourly output}
2021
2022%------------------------------------------nam_diatmb-----------------------------------------------------
2023
2024\begin{listing}
2025  \nlst{nam_diatmb}
2026  \caption{\forcode{&nam_diatmb}}
2027  \label{lst:nam_diatmb}
2028\end{listing}
2029%----------------------------------------------------------------------------------------------------------
2030
2031A module is available to output the surface (top), mid water and bed diagnostics of a set of standard variables.
2032This can be a useful diagnostic when hourly or sub-hourly output is required in high resolution tidal outputs.
2033The tidal signal is retained but the overall data usage is cut to just three vertical levels.
2034Also the bottom level is calculated for each cell.
2035This diagnostic is actived with the logical $ln\_diatmb$.
2036
2037% -----------------------------------------------------------
2038%     Courant numbers
2039% -----------------------------------------------------------
2040\subsection{Courant numbers}
2041
2042Courant numbers provide a theoretical indication of the model's numerical stability.
2043The advective Courant numbers can be calculated according to
2044
2045\[
2046  C_u = |u|\frac{\rdt}{e_{1u}}, \quad C_v = |v|\frac{\rdt}{e_{2v}}, \quad C_w = |w|\frac{\rdt}{e_{3w}}
2047  % \label{eq:DIA_CFL}
2048\]
2049
2050in the zonal, meridional and vertical directions respectively.
2051The vertical component is included although it is not strictly valid as the vertical velocity is calculated from
2052the continuity equation rather than as a prognostic variable.
2053Physically this represents the rate at which information is propogated across a grid cell.
2054Values greater than 1 indicate that information is propagated across more than one grid cell in a single time step.
2055
2056The variables can be activated by setting the \np{nn_diacfl}{nn\_diacfl} namelist parameter to 1 in the \nam{ctl}{ctl} namelist.
2057The diagnostics will be written out to an ascii file named cfl\_diagnostics.ascii.
2058In this file the maximum value of $C_u$, $C_v$, and $C_w$ are printed at each timestep along with the coordinates of
2059where the maximum value occurs.
2060At the end of the model run the maximum value of $C_u$, $C_v$, and $C_w$ for the whole model run is printed along
2061with the coordinates of each.
2062The maximum values from the run are also copied to the ocean.output file.
2063
2064\onlyinsubfile{\input{../../global/epilogue}}
2065
2066\end{document}
Note: See TracBrowser for help on using the repository browser.