Skip to content
Snippets Groups Projects
chap_DIA.tex 106 KiB
Newer Older
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567
    \hline
    field                                                                                   &
    define a specific field                                                                 &
    axis\_ref, default\_value, domain\_ref, enabled, field\_ref, grid\_ref,
    id, level, long\_name, name, operation, prec, standard\_name, unit                      &
    field\_definition, field\_group, file                                                   &
    none                  \\
    \hline
  \end{tabularx}
  \caption{XIOS: field tags ("\texttt{field\_*}")}
\end{table}

\begin{table}
  \begin{tabularx}{\textwidth}{|l|X|X|X|l|}
    \hline
    tag name                                                            &
    description                                                         &
    accepted attribute                                                  &
    child of                                                            &
    parent of           \\
    \hline
    \hline
    file\_definition                                                    &
    encapsulates the definition of all the files that will be outputted &
    enabled, min\_digits, name, name\_suffix, output\_level,
    split\_freq\_format, split\_freq, sync\_freq, type, src             &
    context                                                             &
    file or file\_group \\
    \hline
    file\_group                                                         &
    encapsulates a group of files that will be outputted                &
    enabled, description, id, min\_digits, name, name\_suffix, output\_freq, output\_level,
    split\_freq\_format, split\_freq, sync\_freq, type, src             &
    file\_definition, file\_group                                       &
    file or file\_group \\
    \hline
    file                                                                &
    define the contents of a file to be outputted                       &
    enabled, description, id, min\_digits, name, name\_suffix, output\_freq, output\_level,
    split\_freq\_format, split\_freq, sync\_freq, type, src             &
    file\_definition, file\_group                                       &
    field               \\
    \hline
  \end{tabularx}
  \caption{XIOS: file tags ("\texttt{file\_*}")}
\end{table}

\begin{table}
  \begin{tabularx}{\textwidth}{|l|X|X|X|X|}
    \hline
    tag name                                                                               &
    description                                                                            &
    accepted attribute                                                                     &
    child of                                                                               &
    parent of         \\
    \hline
    \hline
    axis\_definition                                                                       &
    define all the vertical axis potentially used by the variables                         &
    src                                                                                    &
    context                                                                                &
    axis\_group, axis \\
    \hline
    axis\_group                                                                            &
    encapsulates a group of vertical axis                                                  &
    id, lon\_name, positive, src, standard\_name, unit, zoom\_begin, zoom\_end, zoom\_size &
    axis\_definition, axis\_group                                                          &
    axis\_group, axis \\
    \hline
    axis                                                                                   &
    define a vertical axis                                                                 &
    id, lon\_name, positive, src, standard\_name, unit, zoom\_begin, zoom\_end, zoom\_size &
    axis\_definition, axis\_group                                                          &
    none					\\
    \hline
  \end{tabularx}
  \caption{XIOS: axis tags ("\texttt{axis\_*}")}
\end{table}

\begin{table}
  \begin{tabularx}{\textwidth}{|l|X|X|X|X|}
    \hline
    tag name                                                            &
    description                                                         &
    accepted attribute                                                  &
    child of                                                            &
    parent of               \\
    \hline
    \hline
    domain\_\-definition                                                &
    define all the horizontal domains potentially used by the variables &
    src                                                                 &
    context                                                             &
    domain\_\-group, domain \\
    \hline
    domain\_group                                                       &
    encapsulates a group of horizontal domains                          &
    id, lon\_name, src, zoom\_ibegin, zoom\_jbegin, zoom\_ni, zoom\_nj  &
    domain\_\-definition, domain\_group                                 &
    domain\_\-group, domain \\
    \hline
    domain                                                              &
    define an horizontal domain                                         &
    id, lon\_name, src, zoom\_ibegin, zoom\_jbegin, zoom\_ni, zoom\_nj  &
    domain\_\-definition, domain\_group                                 &
    none                    \\
    \hline
  \end{tabularx}
  \caption{XIOS: domain tags ("\texttt{domain\_*)}"}
\end{table}

\begin{table}
  \begin{tabularx}{\textwidth}{|l|X|X|X|X|}
    \hline
    tag name                                                                                     &
    description                                                                                  &
    accepted attribute                                                                           &
    child of                                                                                     &
    parent of                       \\
    \hline
    \hline
    grid\_definition                                                                               &
    define all the grid (association of a domain and/or an axis) potentially used by the variables &
    src                                                                                            &
    context                                                                                        &
    grid\_group, grid	\\
    \hline
    grid\_group                                                                                    &
    encapsulates a group of grids                                                                  &
    id, domain\_ref,axis\_ref                                                                      &
    grid\_definition, grid\_group                                                                  &
    grid\_group, grid	\\
    \hline
    grid                                                                                           &
    define a grid                                                                                  &
    id, domain\_ref,axis\_ref                                                                      &
    grid\_definition, grid\_group                                                                  &
    none 					\\
    \hline
  \end{tabularx}
  \caption{XIOS: grid tags ("\texttt{grid\_*}")}
\end{table}

%% =================================================================================================
\subsubsection{Attributes list per family}

\begin{table}
  \begin{tabularx}{\textwidth}{|l|X|l|l|}
    \hline
    attribute name                           &
    description                              &
    example                                  &
    accepted by            \\
    \hline
    \hline
    axis\_ref                                &
    refers to the id of a vertical axis      &
    axis\_ref="deptht"                       &
    field, grid families   \\
    \hline
    domain\_ref                              &
    refers to the id of a domain             &
    domain\_ref="grid\_T"                    &
    field or grid families \\
    \hline
    field\_ref                               &
    id of the field we want to add in a file &
    field\_ref="toce"                        &
    field                  \\
    \hline
    grid\_ref                                &
    refers to the id of a grid               &
    grid\_ref="grid\_T\_2D"                  &
    field family           \\
    \hline
    group\_ref                               &
    refer to a group of variables            &
    group\_ref="mooring"                     &
    field\_group           \\
    \hline
  \end{tabularx}
  \caption{XIOS: reference attributes ("\texttt{*\_ref}")}
\end{table}

\begin{table}
  \begin{tabularx}{\textwidth}{|l|X|l|l|}
    \hline
    attribute name                                     &
    description                                        &
    example                                            &
    accepted by   \\
    \hline
    \hline
    zoom\_ibegin                                       &
    starting point along x direction of the zoom.
    Automatically defined for TAO/RAMA/PIRATA moorings &
    zoom\_ibegin="1"                                   &
    domain family \\
    \hline
    zoom\_jbegin                                       &
    starting point along y direction of the zoom.
    Automatically defined for TAO/RAMA/PIRATA moorings &
    zoom\_jbegin="1"                                   &
    domain family \\
    \hline
    zoom\_ni                                           &
    zoom extent along x direction                      &
    zoom\_ni="1"                                       &
    domain family \\
    \hline
    zoom\_nj                                           &
    zoom extent along y direction                      &
    zoom\_nj="1"                                       &
    domain family \\
    \hline
  \end{tabularx}
  \caption{XIOS: domain attributes ("\texttt{zoom\_*}")}
\end{table}

\begin{table}
  \begin{tabularx}{\textwidth}{|l|X|l|l|}
    \hline
    attribute name                                                                                       &
    description                                                                                          &
    example                                                                                              &
    accepted by                            \\
    \hline
    \hline
    min\_digits                                                                                          &
    specify the minimum of digits used in the core number in the name of the NetCDF file                 &
    min\_digits="4"                                                                                      &
    file family                            \\
    \hline
    name\_suffix                                                                                         &
    suffix to be inserted after the name and before the cpu number and the ''.nc'' termination of a file &
    name\_suffix="\_myzoom"                                                                              &
    file family                            \\
    \hline
    output\_level                                                                                        &
    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.                                 &
    output\_level="10"                                                                                   &
    file family                            \\
    \hline
    split\_freq                                                                                          &
    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.                                             &
    split\_freq="1mo"                                                                                    &
    file family                            \\
    \hline
    split\_freq\-\_format                                                                                &
    date format used in the name of temporally split output files.
    Can be specified using the following syntaxes: \%y, \%mo, \%d, \%h \%mi and \%s                      &
    split\_freq\_format= "\%y\%mo\%d"                                                                    &
    file family                            \\
    \hline
    sync\_freq                                                                                           &
    NetCDF file synchronization frequency (update of the time\_counter).
    Units can be ts (timestep), y, mo, d, h, mi, s.                                                      &
    sync\_freq="10d"                                                                                     &
    file family                            \\
    \hline
    type (1)                                                                                             &
    specify if the output files are to be split spatially (multiple\_file) or not (one\_file)            &
    type="multiple\_file"                                                                                &
    file familly                           \\
    \hline
  \end{tabularx}
  \caption{XIOS: file attributes}
\end{table}

\begin{table}
  \begin{tabularx}{\textwidth}{|l|X|l|l|}
    \hline
    attribute name                                                                                       &
    description                                                                                          &
    example                                                                                              &
    accepted by                            \\
    \hline
    \hline
    default\_value                                                                                       &
    missing\_value definition                                                                            &
    default\_value="1.e20"                                                                               &
    field family                           \\
    \hline
    level                                                                                                &
    output priority of a field: 0 (high) to 10 (low)                                                     &
    level="1"                                                                                            &
    field family                           \\
    \hline
    operation                                                                                            &
    type of temporal operation: average, accumulate, instantaneous, min, max and once                    &
    operation="average"                                                                                  &
    field family                           \\
    \hline
    output\_freq                                                                                         &
    operation frequency. units can be ts (timestep), y, mo, d, h, mi, s.                                 &
    output\_freq="1d12h"                                                                                 &
    field family                           \\
    \hline
    prec                                                                                                 &
    output precision: real 4 or real 8                                                                   &
    prec="4"                                                                                             &
    field family                           \\
    \hline
    long\_name                                                                                           &
    define the long\_name attribute in the NetCDF file                                                   &
    long\_name="Vertical T levels"                                                                       &
    field                                  \\
    \hline
    standard\_name                                                                                       &
    define the standard\_name attribute in the NetCDF file                                               &
    standard\_name= "Eastward\_Sea\_Ice\_Transport"                                                      &
    field                                  \\
    \hline
  \end{tabularx}
  \caption{XIOS: field attributes}
\end{table}

\begin{table}
  \begin{tabularx}{\textwidth}{|l|X|X|X|}
    \hline
    attribute name                                                                                       &
    description                                                                                          &
    example                                                                                              &
    accepted by                            \\
    \hline
    \hline
    enabled                                                                                              &
    switch on/off the output of a field or a file                                                        &
    enabled=".true."                                                                                     &
    field, file families                   \\
    \hline
    description                                                                                          &
    just for information, not used                                                                       &
    description="ocean T grid variables"                                                                 &
    all tags                               \\
    \hline
    id                                                                                                   &
    allow to identify a tag                                                                              &
    id="nemo"                                                                                            &
    accepted by all tags except simulation \\
    \hline
    name                                                                                                 &
    name of a variable or a file. If the name of a file is undefined, its id is used as a name           &
    name="tos"                                                                                           &
    field or file families                 \\
    \hline
    positive                                                                                             &
    convention used for the orientation of vertival axis (positive downward in \NEMO).                   &
    positive="down"                                                                                      &
    axis family                            \\
    \hline
    src                                                                                                  &
    allow to include a file                                                                              &
    src="./field\_def.xml"                                                                               &
    accepted by all tags except simulation \\
    \hline
    time\_origin                                                                                         &
    specify the origin of the time counter                                                               &
    time\_origin="1900-01-01 00:00:00"                                                                   &
    context                                \\
    \hline
    type (2)                                                                                             &
    define the type of a variable tag                                                                    &
    type="boolean"                                                                                       &
    variable                               \\
    \hline
    unit                                                                                                 &
    unit of a variable or the vertical axis                                                              &
    unit="m"                                                                                             &
    field and axis families                \\
    \hline
  \end{tabularx}
  \caption{XIOS: miscellaneous attributes}
\end{table}

%% =================================================================================================
\subsection{CF metadata standard compliance}

Output from the XIOS IO server is compliant with
\href{http://cfconventions.org/Data/cf-conventions/cf-conventions-1.5/build/cf-conventions.html}{version 1.5} of
the CF metadata standard.
Therefore while a user may wish to add their own metadata to the output files (as demonstrated in example 4 of
section \autoref{subsec:DIA_IOM_xmlref}) the metadata should, for the most part, comply with the CF-1.5 standard.

Some metadata that may significantly increase the file size (horizontal cell areas and vertices) are controlled by
the namelist parameter \np{ln_cfmeta}{ln\_cfmeta} in the \nam{run}{run} namelist.
This must be set to true if these metadata are to be included in the output files.

%% =================================================================================================
\subsection{Enabling NetCDF4 compression with XIOS}

XIOS supports the use of gzip compression when compiled with NetCDF4 libraries but is subject to the
same restrictions as the underlying HDF5 component. That is, compression is not availiable when the
IO servers are writing in parallel to shared output files. Thus, compression can only be applied in
multiple\_file mode only or with two-levels of servers with multiple servers feeding a single server.
The XML tag to activate compression is:

\begin{xmllines}
   compression_level="n"
\end{xmllines}

where n is an integer between 0 and 9. A value of 2 is normally recommended as a suitable trade-off between
algorithm performance and compression levels. This tag can be applied either at file level or to indivdual
fields, e.g.:

\begin{xmllines}
   <file_definition>
      <file name="output" output_freq="1ts" compression_level="2">
         <field id="field_A" grid_ref="grid_A" operation="average" compression_level=" 4" />
         <field id="field_B" grid_ref="grid_A" operation="average" compression_level=" 0" />
         <field id="field_C" grid_ref="grid_A" operation="average" />
      </file> 
   </file_definition>
\end{xmllines}

It is unclear how XIOS decides on suitable chunking parameters before applying compression so it may
be necessary to rechunk data whilst combining multiple\_file output. \forcode{REBUILD_NEMO} is capable
of doing this.

\section[NetCDF4 support (\texttt{\textbf{key\_netcdf4}})]{NetCDF4 support (\protect\key{netcdf4})}
\label{sec:DIA_nc4}

Since version 3.3, support for NetCDF4 chunking and (loss-less) compression has been
included.  These options build on the standard NetCDF output and allow the user control
over the size of the chunks via namelist settings.  Chunking and compression can lead to
significant reductions in file sizes for a small runtime overhead.  For a fuller
discussion on chunking and other performance issues the reader is referred to the NetCDF4
documentation found
\href{https://www.unidata.ucar.edu/software/netcdf/docs/netcdf_perf_chunking.html}{here}.

This section only applies to the NetCDF output written directly by \NEMO; i.e. restart
files and mean files produced via the old IOIPSL interface when \key{xios} is not being
used. As such it has limited use since chunking and compression can be applied at the
rebuilding phase of such output.

The features are only available when the code has been linked with a NetCDF4 library
(version 4.1 onwards, recommended) which has been built with HDF5 support (version 1.8.4
onwards, recommended).  Datasets created with chunking and compression are not backwards
compatible with NetCDF3 "classic" format but most analysis codes can be relinked simply
with the new libraries and will then read both NetCDF3 and NetCDF4 files.  \NEMO\
executables linked with NetCDF4 libraries can be made to produce NetCDF3 files by setting
the \np{ln_nc4zip}{ln\_nc4zip} logical to false in the \nam{nc4}{nc4} namelist:

\begin{listing}
  \nlst{namnc4}
  \caption{\forcode{&namnc4}}
  \label{lst:namnc4}
\end{listing}

If \key{netcdf4} has not been defined, these namelist parameters are not read.  In this
case, \np{ln_nc4zip}{ln\_nc4zip} is set false and dummy routines for a few
NetCDF4-specific functions are defined.  These functions will not be used but need to be
included so that compilation is possible with NetCDF3 libraries.

When using NetCDF4 libraries, \key{netcdf4} should be defined even if the intention is to
create only NetCDF3-compatible files.  This is necessary to avoid duplication between the
dummy routines and the actual routines present in the library.  Most compilers will fail
at compile time when faced with such duplication.  Thus when linking with NetCDF4
libraries the user must define \key{netcdf4} and control the type of NetCDF file produced
via the namelist parameter.

Chunking and compression is applied only to 4D fields and there is no advantage in
chunking across more than one time dimension since previously written chunks would have to
be read back and decompressed before being added to.  Therefore, user control over chunk
sizes is provided only for the three space dimensions.  The user sets an approximate
number of chunks along each spatial axis.  The actual size of the chunks will depend on
global domain size for mono-processors or, more likely, the local processor domain size
for distributed processing.  The derived values are subject to practical minimum values
(to avoid wastefully small chunk sizes) and cannot be greater than the domain size in any
dimension.  The algorithm used is:

\begin{forlines}
ichunksz(1) = MIN(idomain_size, MAX((idomain_size-1) / nn_nchunks_i + 1 ,16 ))
ichunksz(2) = MIN(jdomain_size, MAX((jdomain_size-1) / nn_nchunks_j + 1 ,16 ))
ichunksz(3) = MIN(kdomain_size, MAX((kdomain_size-1) / nn_nchunks_k + 1 , 1 ))
ichunksz(4) = 1
\end{forlines}

\noindent As an example, setting:

\begin{forlines}
nn_nchunks_i=4, nn_nchunks_j=4 and nn_nchunks_k=31
\end{forlines}

\noindent for a standard ORCA2\_LIM configuration gives chunksizes of {\small\texttt 46x38x1} respectively in
the mono-processor case (\ie\ global domain of {\small\texttt 182x149x31}).
An illustration of the potential space savings that NetCDF4 chunking and compression provides is given in
table \autoref{tab:DIA_NC4} which compares the results of two short runs of the ORCA2\_LIM reference configuration with
a 4x2 mpi partitioning.
Note the variation in the compression ratio achieved which reflects chiefly the dry to wet volume ratio of
each processing region.

\begin{table}
  \centering
  \begin{tabular}{lrrr}
    Filename                    & NetCDF3	& NetCDF4  & Reduction \\
                                & filesize	& filesize & \%        \\
                                & (KB)		& (KB)	  &           \\
    ORCA2\_restart\_0000.nc     & 16420 	& 8860 	  & 47\%      \\
    ORCA2\_restart\_0001.nc     & 16064 	& 11456    & 29\%      \\
    ORCA2\_restart\_0002.nc     & 16064		& 9744	  & 40\%      \\
    ORCA2\_restart\_0003.nc     & 16420		& 9404	  & 43\%      \\
    ORCA2\_restart\_0004.nc     & 16200 	& 5844	  & 64\%      \\
    ORCA2\_restart\_0005.nc     & 15848 	& 8172	  & 49\%      \\
    ORCA2\_restart\_0006.nc     & 15848 	& 8012 	  & 50\%      \\
    ORCA2\_restart\_0007.nc     & 16200 	& 5148 	  & 69\%      \\
    ORCA2\_2d\_grid\_T\_0000.nc & 2200 		& 1504	  & 32\%      \\
    ORCA2\_2d\_grid\_T\_0001.nc & 2200 		& 1748	  & 21\%      \\
    ORCA2\_2d\_grid\_T\_0002.nc & 2200 		& 1592	  & 28\%      \\
    ORCA2\_2d\_grid\_T\_0003.nc & 2200 		& 1540	  & 30\%      \\
    ORCA2\_2d\_grid\_T\_0004.nc & 2200 		& 1204	  & 46\%      \\
    ORCA2\_2d\_grid\_T\_0005.nc & 2200 		& 1444	  & 35\%      \\
    ORCA2\_2d\_grid\_T\_0006.nc & 2200 		& 1428	  & 36\%      \\
    ORCA2\_2d\_grid\_T\_0007.nc & 2200		& 1148	  & 48\%      \\
    ...                         & ...		& ...      & ...       \\
    ORCA2\_2d\_grid\_W\_0000.nc & 4416		& 2240	  & 50\%      \\
    ORCA2\_2d\_grid\_W\_0001.nc & 4416		& 2924	  & 34\%      \\
    ORCA2\_2d\_grid\_W\_0002.nc & 4416		& 2512	  & 44\%      \\
    ORCA2\_2d\_grid\_W\_0003.nc & 4416		& 2368	  & 47\%      \\
    ORCA2\_2d\_grid\_W\_0004.nc & 4416		& 1432	  & 68\%      \\
    ORCA2\_2d\_grid\_W\_0005.nc & 4416		& 1972	  & 56\%      \\
    ORCA2\_2d\_grid\_W\_0006.nc & 4416		& 2028	  & 55\%      \\
    ORCA2\_2d\_grid\_W\_0007.nc & 4416		& 1368	  & 70\%      \\
  \end{tabular}
  \caption{Filesize comparison between NetCDF3 and NetCDF4 with chunking and compression}
  \label{tab:DIA_NC4}
\end{table}

%% =================================================================================================
\section[Tracer/Dynamics trends (\forcode{&namtrd})]{Tracer/Dynamics trends (\protect\nam{trd}{trd})}
\label{sec:DIA_trd}

\begin{listing}
  \nlst{namtrd}
  \caption{\forcode{&namtrd}}
  \label{lst:namtrd}
\end{listing}

Each trend of the dynamics and/or temperature and salinity time evolution equations can be send to
\mdl{trddyn} and/or \mdl{trdtra} modules (see TRD directory) just after their computation
(\ie\ at the end of each \textit{dyn....F90} and/or \textit{tra....F90} routines).
This capability is controlled by options offered in \nam{trd}{trd} namelist.
Note that the output are done with XIOS, and therefore the \key{xios} is required.

What is done depends on the \nam{trd}{trd} logical set to \forcode{.true.}:

\begin{description}
\item [{\np{ln_glo_trd}{ln\_glo\_trd}}]: at each \np{nn_trd}{nn\_trd} time-step a check of the basin averaged properties of
  the momentum and tracer equations is performed.
  This also includes a check of $T^2$, $S^2$, $\tfrac{1}{2} (u^2+v2)$,
  and potential energy time evolution equations properties;
\item [{\np{ln_dyn_trd}{ln\_dyn\_trd}}]: each 3D trend of the evolution of the two momentum components is output;
\item [{\np{ln_dyn_mxl}{ln\_dyn\_mxl}}]: each 3D trend of the evolution of the two momentum components averaged over the mixed layer is output;
\item [{\np{ln_vor_trd}{ln\_vor\_trd}}]: a vertical summation of the moment tendencies is performed,
  then the curl is computed to obtain the barotropic vorticity tendencies which are output;
\item [{\np{ln_KE_trd}{ln\_KE\_trd}}]  : each 3D trend of the Kinetic Energy equation is output;
\item [{\np{ln_tra_trd}{ln\_tra\_trd}}]: each 3D trend of the evolution of temperature and salinity is output;
\item [{\np{ln_tra_mxl}{ln\_tra\_mxl}}]: each 2D trend of the evolution of temperature and salinity averaged over the mixed layer is output;
\end{description}

Note that the mixed layer tendency diagnostic can also be used on biogeochemical models via
the \key{trdtrc} and \key{trdmxl\_trc} CPP keys.

\textbf{Note that} in the current version, many changes has been introduced but not fully tested.
In particular, options associated with \np{ln_dyn_mxl}{ln\_dyn\_mxl}, \np{ln_vor_trd}{ln\_vor\_trd}, and \np{ln_tra_mxl}{ln\_tra\_mxl} are not working,
and none of the options have been tested with variable volume (\ie\ \np[=.true.]{ln_linssh}{ln\_linssh}).

%% =================================================================================================
\section[FLO: On-Line Floats trajectories]{FLO: On-Line Floats trajectories}
\label{sec:DIA_FLO}

\begin{listing}
  \nlst{namflo}
  \caption{\forcode{&namflo}}
  \label{lst:namflo}
\end{listing}

The on-line computation of floats advected either by the three dimensional velocity field or constraint to
remain at a given depth ($w = 0$ in the computation) have been introduced in the system during the CLIPPER project.
Options are defined by \nam{flo}{flo} namelist variables and the interface is activated by setting \np[=.true.]{ln_float}{ln\_float}.

The algorithm used is based either on the work of \cite{blanke.raynaud_JPO97} (default option),
or on a $4^th$ Runge-Hutta algorithm (\np[=.true.]{ln_flork4}{ln\_flork4}).
Note that the \cite{blanke.raynaud_JPO97} algorithm have the advantage of providing trajectories which
are consistent with the numeric of the code, so that the trajectories never intercept the bathymetry.

%% =================================================================================================
\subsubsection{Input data: initial coordinates}

Initial coordinates can be given with Ariane Tools convention
(IJK coordinates, (\np[=.true.]{ln_ariane}{ln\_ariane}) ) or with longitude and latitude.

In case of Ariane convention, input filename is \textit{init\_float\_ariane}.
Its format is: \\
{ \texttt{I J K nisobfl itrash}}

\noindent with:

 - I,J,K  : indexes of initial position

 - nisobfl: 0 for an isobar float, 1 for a float following the w velocity

 - itrash : set to zero; it is a dummy variable to respect Ariane Tools convention

\noindent Example: \\
\noindent
{
  \texttt{
    100.00000  90.00000  -1.50000 1.00000   0.00000   \\
    102.00000  90.00000  -1.50000 1.00000   0.00000   \\
    104.00000  90.00000  -1.50000 1.00000   0.00000   \\
    106.00000  90.00000  -1.50000 1.00000   0.00000   \\
    108.00000  90.00000  -1.50000 1.00000   0.00000}
} \\

In the other case (longitude and latitude), input filename is init\_float.
Its format is: \\
{ \texttt{Long Lat depth nisobfl ngrpfl itrash}}

\noindent with:

 - Long, Lat, depth  : Longitude, latitude, depth

 - nisobfl: 0 for an isobar float, 1 for a float following the w velocity

 - ngrpfl : number to identify searcher group

 - itrash :set to 1; it is a dummy variable.

\noindent Example: \\
\noindent
{
  \texttt{
    20.0 0.0 0.0 0 1 1    \\
    -21.0 0.0 0.0 0 1 1    \\
    -22.0 0.0 0.0 0 1 1    \\
    -23.0 0.0 0.0 0 1 1    \\
    -24.0 0.0 0.0 0 1 1 }
} \\

\np{jpnfl}{jpnfl} is the total number of floats during the run.
When initial positions are read in a restart file (\np[=.true.]{ln_rstflo}{ln\_rstflo} ),
\np{jpnflnewflo}{jpnflnewflo} can be added in the initialization file.

%% =================================================================================================
\subsubsection{Output data}

\np{nn_writefl}{nn\_writefl} is the frequency of writing in float output file and \np{nn_stockfl}{nn\_stockfl} is the frequency of
creation of the float restart file.

Output data can be written in ascii files (\np[=.true.]{ln_flo_ascii}{ln\_flo\_ascii}).
In that case, output filename is trajec\_float.

Another possiblity of writing format is Netcdf (\np[=.false.]{ln_flo_ascii}{ln\_flo\_ascii}) with
\key{xios} and outputs selected in iodef.xml.
Here it is an example of specification to put in files description section:

\begin{xmllines}
<group id="1d_grid_T" name="auto" description="ocean T grid variables" >
   <file id="floats"  description="floats variables">
      <field ref="traj_lon"   name="floats_longitude"   freq_op="86400" />
      <field ref="traj_lat"   name="floats_latitude"    freq_op="86400" />
      <field ref="traj_dep"   name="floats_depth"       freq_op="86400" />
      <field ref="traj_temp"  name="floats_temperature" freq_op="86400" />
      <field ref="traj_salt"  name="floats_salinity"    freq_op="86400" />
      <field ref="traj_dens"  name="floats_density"     freq_op="86400" />
      <field ref="traj_group" name="floats_group"       freq_op="86400" />
   </file>
</group>
\end{xmllines}

%% =================================================================================================
\section[Transports across sections]{Transports across sections}
\label{sec:DIA_diag_dct}

\begin{listing}
  \nlst{nam_diadct}
  \caption{\forcode{&nam_diadct}}
  \label{lst:nam_diadct}
\end{listing}

A module is available to compute the transport of volume, heat and salt through sections.
This diagnostic is actived with \np[=.true.]{ln_diadct}{ln\_diadct}.

Each section is defined by the coordinates of its 2 extremities.
The pathways between them are contructed using tools which can be found in \texttt{tools/SECTIONS\_DIADCT}
and are written in a binary file \texttt{section\_ijglobal.diadct} which is later read in by
\NEMO\ to compute on-line transports.

The on-line transports module creates three output ascii files:

- \texttt{volume\_transport} for volume transports (unit: $10^{6} m^{3} s^{-1}$)

- \texttt{heat\_transport}   for   heat transports (unit: $10^{15} W$)

- \texttt{salt\_transport}   for   salt transports (unit: $10^{9}Kg s^{-1}$) \\

Namelist variables in \nam{_diadct}{\_diadct} control how frequently the flows are summed and the time scales over which
they are averaged, as well as the level of output for debugging:
\np{nn_dct}{nn\_dct}   : frequency of instantaneous transports computing
\np{nn_dctwri}{nn\_dctwri}: frequency of writing ( mean of instantaneous transports )
\np{nn_debug}{nn\_debug} : debugging of the section

%% =================================================================================================
\subsubsection{Creating a binary file containing the pathway of each section}

In \texttt{tools/SECTIONS\_DIADCT/run},
the file \textit{{list\_sections.ascii\_global}} contains a list of all the sections that are to be computed
(this list of sections is based on MERSEA project metrics).

Another file is available for the GYRE configuration (\texttt{ {list\_sections.ascii\_GYRE}}).

Each section is defined by: \\
\noindent { \texttt{long1 lat1 long2 lat2 nclass (ok/no)strpond (no)ice section\_name}} \\
with:

 - \texttt{long1 lat1}, coordinates of the  first extremity of the section;

 - \texttt{long2 lat2}, coordinates of the second extremity of the section;

 - \texttt{nclass}    the number of bounds of your classes (\eg\ bounds for 2 classes);

 - \texttt{okstrpond} to compute    heat and       salt transports, \texttt{nostrpond} if no;

 - \texttt{ice}       to compute surface and volume ice transports, \texttt{noice}     if no. \\

 \noindent The results of the computing of transports, and the directions of positive and
 negative flow do not depend on the order of the 2 extremities in this file. \\

\noindent If nclass $\neq$ 0, the next lines contain the class type and the nclass bounds: \\
{
  \texttt{
    long1 lat1 long2 lat2 nclass (ok/no)strpond (no)ice section\_name \\
    classtype                                                         \\
    zbound1                                                           \\
    zbound2                                                           \\
    .                                                                 \\
    .                                                                 \\
    nclass-1                                                          \\
    nclass}
}

\noindent where \texttt{classtype} can be:

 - \texttt{zsal}  for          salinity classes

 - \texttt{ztem}  for       temperature classes

 - \texttt{zlay}  for             depth classes

 - \texttt{zsigi} for    insitu density classes

 - \texttt{zsigp} for potential density classes \\

 The script \texttt{job.ksh} computes the pathway for each section and creates a binary file
 \texttt{section\_ijglobal.diadct} which is read by \NEMO. \\

 It is possible to use this tools for new configuations: \texttt{job.ksh} has to be updated with
 the coordinates file name and path. \\

 Examples of two sections, the ACC\_Drake\_Passage with no classes,
 and the ATL\_Cuba\_Florida with 4 temperature clases (5 class bounds), are shown: \\
 \noindent
 {
   \texttt{
     -68.    -54.5   -60.    -64.7  00 okstrpond noice ACC\_Drake\_Passage \\
     -80.5    22.5   -80.5    25.5  05 nostrpond noice ATL\_Cuba\_Florida  \\
     ztem                                                                  \\
     -2.0                                                                  \\
     4.5                                                                  \\
     7.0                                                                  \\
     12.0                                                                  \\
     40.0}
 }

%% =================================================================================================
\subsubsection{To read the output files}

The output format is: \\
{
  \texttt{
    date, time-step number, section number,                \\
    section name, section slope coefficient, class number, \\
    class name, class bound 1 , classe bound2,             \\
    transport\_direction1, transport\_direction2,          \\
    transport\_total}
}                                     \\

For sections with classes, the first \texttt{nclass-1} lines correspond to the transport for each class and
the last line corresponds to the total transport summed over all classes.
For sections with no classes, class number \texttt{1} corresponds to \texttt{total class} and
this class is called \texttt{N}, meaning \texttt{none}.

- \texttt{transport\_direction1} is the positive part of the transport ($\geq$ 0).

- \texttt{transport\_direction2} is the negative part of the transport ($\leq$ 0). \\

\noindent The \texttt{section slope coefficient} gives information about the significance of transports signs and
direction: \\

\begin{table}
  \begin{tabular}{|l|l|l|l|l|}
    \hline
    section slope coefficient      & section type & direction 1 & direction 2 & total transport    \\
    \hline
    0.                             & horizontal	 & northward	& southward   & postive: northward    \\
    \hline
    1000.                          & vertical     & eastward    & westward    & postive: eastward		\\
    \hline
    \texttt{$\neq$ 0, $\neq$ 1000.} & diagonal     & eastward    & westward	  & postive: eastward		\\
    \hline
  \end{tabular}
\end{table}

%% =================================================================================================
\section{Diagnosing the steric effect in sea surface height}
\label{sec:DIA_steric}

Changes in steric sea level are caused when changes in the density of the water column imply an expansion or
contraction of the column.
It is essentially produced through surface heating/cooling and to a lesser extent through non-linear effects of
the equation of state (cabbeling, thermobaricity...).
Non-Boussinesq models contain all ocean effects within the ocean acting on the sea level.
In particular, they include the steric effect.
In contrast, Boussinesq models, such as \NEMO, conserve volume, rather than mass,
and so do not properly represent expansion or contraction.
The steric effect is therefore not explicitely represented.
This approximation does not represent a serious error with respect to the flow field calculated by the model
\citep{greatbatch_JGR94}, but extra attention is required when investigating sea level,
as steric changes are an important contribution to local changes in sea level on seasonal and climatic time scales.
This is especially true for investigation into sea level rise due to global warming.

Fortunately, the steric contribution to the sea level consists of a spatially uniform component that
can be diagnosed by considering the mass budget of the world ocean \citep{greatbatch_JGR94}.
In order to better understand how global mean sea level evolves and thus how the steric sea level can be diagnosed,
we compare, in the following, the non-Boussinesq and Boussinesq cases.

Let denote
$\mathcal{M}$ the total mass    of liquid seawater ($\mathcal{M} = \int_D \rho dv$),
$\mathcal{V}$ the total volume  of        seawater      ($\mathcal{V} = \int_D dv$),
$\mathcal{A}$ the total surface of       the ocean      ($\mathcal{A} = \int_S ds$),
$\bar{\rho}$ the global mean  seawater (\textit{in situ}) density
($\bar{\rho} = 1/\mathcal{V} \int_D \rho \,dv$), and
$\bar{\eta}$ the global mean sea level
($\bar{\eta} = 1/\mathcal{A} \int_S \eta \,ds$).

A non-Boussinesq fluid conserves mass. It satisfies the following relations:

\begin{equation}
  \begin{split}
    \mathcal{M} &=  \mathcal{V}  \;\bar{\rho} \\
    \mathcal{V} &=  \mathcal{A}  \;\bar{\eta}
  \end{split}
  \label{eq:DIA_MV_nBq}
\end{equation}

Temporal changes in total mass is obtained from the density conservation equation:

\begin{equation}
  \frac{1}{e_3} \partial_t ( e_3\,\rho) + \nabla( \rho \, \textbf{U} )
  = \left. \frac{\textit{emp}}{e_3}\right|_\textit{surface}
  \label{eq:DIA_Co_nBq}
\end{equation}

where $\rho$ is the \textit{in situ} density, and \textit{emp} the surface mass exchanges with the other media of
the Earth system (atmosphere, sea-ice, land).
Its global averaged leads to the total mass change

\begin{equation}
  \partial_t \mathcal{M} = \mathcal{A} \;\overline{\textit{emp}}
  \label{eq:DIA_Mass_nBq}
\end{equation}

where $\overline{\textit{emp}} = \int_S \textit{emp}\,ds$ is the net mass flux through the ocean surface.
Bringing \autoref{eq:DIA_Mass_nBq} and the time derivative of \autoref{eq:DIA_MV_nBq} together leads to
the evolution equation of the mean sea level

\begin{equation}
  \partial_t \bar{\eta} = \frac{\overline{\textit{emp}}}{ \bar{\rho}}
  - \frac{\mathcal{V}}{\mathcal{A}} \;\frac{\partial_t \bar{\rho} }{\bar{\rho}}
  \label{eq:DIA_ssh_nBq}
\end{equation}

The first term in equation \autoref{eq:DIA_ssh_nBq} alters sea level by adding or subtracting mass from the ocean.
The second term arises from temporal changes in the global mean density; \ie\ from steric effects.

In a Boussinesq fluid, $\rho$ is replaced by $\rho_o$ in all the equation except when $\rho$ appears multiplied by
the gravity (\ie\ in the hydrostatic balance of the primitive Equations).
In particular, the mass conservation equation, \autoref{eq:DIA_Co_nBq}, degenerates into the incompressibility equation:

\[
  \frac{1}{e_3} \partial_t ( e_3 ) + \nabla( \textbf{U} ) = \left. \frac{\textit{emp}}{\rho_o \,e_3}\right|_ \textit{surface}
  % \label{eq:DIA_Co_Bq}
\]

and the global average of this equation now gives the temporal change of the total volume,

\[
  \partial_t \mathcal{V} = \mathcal{A} \;\frac{\overline{\textit{emp}}}{\rho_o}
  % \label{eq:DIA_V_Bq}
\]

Only the volume is conserved, not mass, or, more precisely, the mass which is conserved is the Boussinesq mass,
$\mathcal{M}_o = \rho_o \mathcal{V}$.
The total volume (or equivalently the global mean sea level) is altered only by net volume fluxes across
the ocean surface, not by changes in mean mass of the ocean: the steric effect is missing in a Boussinesq fluid.

Nevertheless, following \citep{greatbatch_JGR94}, the steric effect on the volume can be diagnosed by
considering the mass budget of the ocean.
The apparent changes in $\mathcal{M}$, mass of the ocean, which are not induced by surface mass flux
must be compensated by a spatially uniform change in the mean sea level due to expansion/contraction of the ocean
\citep{greatbatch_JGR94}.
In others words, the Boussinesq mass, $\mathcal{M}_o$, can be related to $\mathcal{M}$,
the total mass of the ocean seen by the Boussinesq model, via the steric contribution to the sea level,
$\eta_s$, a spatially uniform variable, as follows:

\begin{equation}
  \mathcal{M}_o = \mathcal{M} + \rho_o \,\eta_s \,\mathcal{A}
  \label{eq:DIA_M_Bq}
\end{equation}

Any change in $\mathcal{M}$ which cannot be explained by the net mass flux through the ocean surface
is converted into a mean change in sea level.
Introducing the total density anomaly, $\mathcal{D}= \int_D d_a \,dv$,
where $d_a = (\rho -\rho_o ) / \rho_o$ is the density anomaly used in \NEMO\ (cf. \autoref{subsec:TRA_eos})
in \autoref{eq:DIA_M_Bq} leads to a very simple form for the steric height:

\begin{equation}
  \eta_s = - \frac{1}{\mathcal{A}} \mathcal{D}
  \label{eq:DIA_steric_Bq}
\end{equation}

The above formulation of the steric height of a Boussinesq ocean requires four remarks.
First, one can be tempted to define $\rho_o$ as the initial value of $\mathcal{M}/\mathcal{V}$,
\ie\ set $\mathcal{D}_{t=0}=0$, so that the initial steric height is zero.
We do not recommend that.
Indeed, in this case $\rho_o$ depends on the initial state of the ocean.
Since $\rho_o$ has a direct effect on the dynamics of the ocean
(it appears in the pressure gradient term of the momentum equation)
it is definitively not a good idea when inter-comparing experiments.
We better recommend to fixe once for all $\rho_o$ to $1035\;Kg\,m^{-3}$.
This value is a sensible choice for the reference density used in a Boussinesq ocean climate model since,
with the exception of only a small percentage of the ocean, density in the World Ocean varies by no more than
2$\%$ from this value (\cite{gill_bk82}, page 47).

Second, we have assumed here that the total ocean surface, $\mathcal{A}$,
does not change when the sea level is changing as it is the case in all global ocean GCMs
(wetting and drying of grid point is not allowed).

Third, the discretisation of \autoref{eq:DIA_steric_Bq} depends on the type of free surface which is considered.
In the non linear free surface case, \ie\ \np[=.true.]{ln_linssh}{ln\_linssh}, it is given by

\[
  \eta_s = - \frac{ \sum_{i,\,j,\,k} d_a\; e_{1t} e_{2t} e_{3t} }{ \sum_{i,\,j,\,k}       e_{1t} e_{2t} e_{3t} }
  % \label{eq:DIA_discrete_steric_Bq_nfs}
\]

whereas in the linear free surface,
the volume above the \textit{z=0} surface must be explicitly taken into account to
better approximate the total ocean mass and thus the steric sea level:

\[
  \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 }
                  { \sum_{i,\,j,\,k}       e_{1t}e_{2t}e_{3t} + \sum_{i,\,j}       e_{1t}e_{2t} \eta }
  % \label{eq:DIA_discrete_steric_Bq_fs}
\]

The fourth and last remark concerns the effective sea level and the presence of sea-ice.
In the real ocean, sea ice (and snow above it)  depresses the liquid seawater through its mass loading.
This depression is a result of the mass of sea ice/snow system acting on the liquid ocean.
There is, however, no dynamical effect associated with these depressions in the liquid ocean sea level,
so that there are no associated ocean currents.
Hence, the dynamically relevant sea level is the effective sea level,
\ie\ the sea level as if sea ice (and snow) were converted to liquid seawater \citep{campin.marshall.ea_OM08}.
However, in the current version of \NEMO\ the sea-ice is levitating above the ocean without mass exchanges between
ice and ocean.
Therefore the model effective sea level is always given by $\eta + \eta_s$, whether or not there is sea ice present.

In AR5 outputs, the thermosteric sea level is demanded.
It is steric sea level due to changes in ocean density arising just from changes in temperature.
It is given by:

\[
  \eta_s = - \frac{1}{\mathcal{A}} \int_D d_a(T,S_o,p_o) \,dv
  % \label{eq:DIA_thermosteric_Bq}
\]

where $S_o$ and $p_o$ are the initial salinity and pressure, respectively.

Both steric and thermosteric sea level are computed in \mdl{diaar5}.

%% =================================================================================================
\section{Other diagnostics}
\label{sec:DIA_diag_others}

Aside from the standard model variables, other diagnostics can be computed on-line.