source: NEMO/branches/2019/dev_r10984_HPC-13_IRRMANN_BDY_optimization/doc/latex/NEMO/subfiles/chap_DIA.tex @ 11353

Last change on this file since 11353 was 11353, checked in by smasson, 2 years ago

dev_r10984_HPC-13 : merge with trunk@11352, see #2285

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