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

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

Various corrections on chapters

Cleaning the indexes by fixing/removing wrong entries (or appending a ? to unknown items) and
improve the classification with new index definitions for CPP keys and namelist blocks:

  • from \key{...} cmd, key_ prefix no longer precedes the index entry
  • namelist block declaration moves from \ngn{nam...} to \nam{...} (i.e. \ngn{namtra\_ldf} -> \nam{tra\_ldf}) The expected prefix nam is added to the printed word but not the index entry.

Now we have indexes with a better sorting instead of all CPP keys under 'K' and namelists blocks under 'N'.

Fix missing space issues with alias commands by adding a trailing backslash (\NEMO\, \ie\, \eg\, ...).
There is no perfect solution for this, and I prefer not using a particular package to solve it.

Review the initial LaTeX code snippet for the historic changes in chapters

Finally, for readability and future diff visualisations, please avoid writing paragraphs with continuous lines.
Break the lines around 80 to 100 characters long

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