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 @ 11582

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

New LaTeX commands \nam and \np to mention namelist content (step 2)
Finally convert \forcode{...} following \np{}{} into optional arg of the new command \np[]{}{}

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