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/UKMO/dev_r6393_CO6_package_trunk/DOC/TexFiles/Chapters – NEMO

source: branches/UKMO/dev_r6393_CO6_package_trunk/DOC/TexFiles/Chapters/Chap_DIA.tex @ 7019

Last change on this file since 7019 was 7019, checked in by deazer, 8 years ago

Cleared svn keywords

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