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/2015/nemo_v3_6_STABLE/DOC/TexFiles/Chapters – NEMO

source: branches/2015/nemo_v3_6_STABLE/DOC/TexFiles/Chapters/Chap_DIA.tex @ 6275

Last change on this file since 6275 was 6275, checked in by gm, 8 years ago

#1629: DOC of v3.6_stable. Upadate, see associated wiki page for description

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