New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
chap_DIA.tex in branches/2017/dev_merge_2017/DOC/tex_sub – NEMO

source: branches/2017/dev_merge_2017/DOC/tex_sub/chap_DIA.tex @ 9407

Last change on this file since 9407 was 9407, checked in by nicolasmartin, 6 years ago

Complete refactoring of cross-referencing

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