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

Last change on this file since 13970 was 13970, checked in by andmirek, 3 years ago

Ticket #2462 into the trunk

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